欢迎光临
我们一直在努力

AZTransitions

建站超值云服务器,限时71元/月

AZTransitions

项目介绍:

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 Example

Animation example

Installation

  • Add 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 Example

To 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.

code4app

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » AZTransitions
分享到: 更多 (0)