AZTransitions
https://github.com/azimin/AZTransitions
Make your modal transition with custom animation.
AZTransitions helps you think about creativity, giving specific API methods.
AZTransitions 使用自定义动画进行模态转换。提供具体的API方法。
Visual ExampleInstallationAdd the following to your Podfile and run pod install
pod 'AZTransitions'or add the following to your Cartfile and run carthage update
github 'azimin/AZTransitions'or clone as a git submodule,
or just copy AZTransitions/Source/CustomModalTransition.swift into your project.
Code ExampleTo create any custom transition just subclass CustomModalTransition:
class FashionTransition: CustomModalTransition { override init() { super.init(duration: 0.5) } }--
Then set as az_modalTransition to nessesary view just before presenting it
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { segue.destination.customModalTransition = FashionTransition() }or
func show() { let viewController = UIViewController() viewController.az_modalTransition = FashionTransition() self.present(viewController, animated: true, completion: nil) }--
To have custom present animation, just implement performTransition(interactive: Bool) inside your FashionTransition class:
func performTransition(interactive: Bool) { self.presentedViewController.view.alpha = 0.0 UIView.animate(withDuration: duration, animations: { self.presentedViewController.view.alpha = 1.0 self.presentingViewController.view.alpha = 0.0 }, completion: { (completed) in self.presentingViewController.view.alpha = 1.0 self.finishAnimation(completion: nil) }) }As you may have guessed, you have different properties. The main ones:
duration — transition duration
presentingViewController — the presenting view controller (bottom one)
presentedViewController — view controller that is going to be presented (top one)
You can animate them as you want.