CascadePresenter 1.1.2

CascadePresenter 1.1.2

测试已测试
语言语言 SwiftSwift
许可协议 MIT
发布日期上次发布2017年2月
SwiftSwift 版本3.0
SPM支持 SPM

Nick Kibish 维护。



  • git

CascadePresenter

使用方法

要使用动画器,只需将以下代码添加到 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

默认参数

Default_

自定义参数

Custom_

自定义初始帧

Custom_frame_

安装

CascadePresenter 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod "CascadePresenter"

作者

Nick Kibish,[email protected]

许可协议

CascadePresenter 在 MIT 许可协议下提供。有关更多信息,请参阅 LICENSE 文件。