测试已测试 | ✓ |
语言语言 | SwiftSwift |
许可协议 | MIT |
发布日期上次发布 | 2017年2月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Nick Kibish 维护。
要使用动画器,只需将以下代码添加到 UIViewControllerTransitioningDelegate
实例。
extension ViewController: UIViewControllerTransitioningDelegate {
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return Cascade.animator(for: .present)
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return Cascade.animator(for: .dismiss)
}
}
您还可以更改动画参数
struct Params: CascadeAnimationParameters {
var animationDuration: TimeInterval = 1.5
var presentingVCAlpha: CGFloat = 0.97
var presentingTopMargin: CGFloat = 25
var presentedTopMargin: CGFloat = 50
var scale: CGFloat = 1
var backgroundColor: UIColor = .green
var cornerRadius: CGFloat = 15
var presentedInitialFrame: CGRect? = CGRect(x: 0, y: UIScreen.main.bounds.height - 32, width: UIScreen.main.bounds.width, height: 32)
}
// ...
class ViewController: UIViewController {
let params = Params()
}
// ...
extension ViewController: UIViewControllerTransitioningDelegate {
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return Cascade.animator(for: .present, animationParams: params)
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return Cascade.animator(for: .dismiss, animationParams: params)
}
}
并且别忘了为演示视图控制器设置过渡代理。例如
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
segue.destination.transitioningDelegate = self
}
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
默认参数
自定义参数
自定义初始帧
CascadePresenter 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod "CascadePresenter"
Nick Kibish,[email protected]
CascadePresenter 在 MIT 许可协议下提供。有关更多信息,请参阅 LICENSE 文件。