iOSCustomTransitions 0.1.0

iOSCustomTransitions 0.1.0

Charles Lima 维护。



  • 作者:
  • charleslima

iOSCustomTransitions

Screenshot

示例

要运行示例项目,请先克隆仓库,然后从 Example 目录运行 pod install

安装

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

pod 'iOSCustomTransitions'

用法

导入 iOSCustomTransitions

import iOSCustomTransitions

使用自定义过渡时,您的 ViewController 需要符合 UIViewControllerTransitioningDelegate,如下例所示。

extension MyViewController: UIViewControllerTransitioningDelegate {

    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return ZoomingPresentAnimator(originFrame: self.cardButton.frame, transitionStyle: .mixed, originViewSnapshot: self.cardButton.snapshotView(afterScreenUpdates: true))
    }

    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return ZoomingDismissAnimator(destinationFrame: self.cardButton.frame, transitionStyle: .mixed, destinationViewSnapshot: self.cardButton.snapshotView(afterScreenUpdates: false))
    }
}

您还需要将目标 ViewController 的 transitioningDelegate 设置为原始 ViewController

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    segue.destination.transitioningDelegate = self
}

以下列出目前可用的过渡

  • ZoomingPresentAnimator
  • ZoomingDismissAnimator
  • BubblePresentAnimatorController
  • BubbleDismissAnimatorController

作者

charleslima, [email protected]

许可证

iOSCustomTransitions遵循MIT许可证。更多信息请参阅LICENSE文件。