IOS页面跳转动画实现

时间:2018-08-20 04:09:43
【文件属性】:

文件名称:IOS页面跳转动画实现

文件大小:35KB

文件格式:ZIP

更新时间:2018-08-20 04:09:43

跳转动画

func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval { return 1.0 } func animateTransition(transitionContext: UIViewControllerContextTransitioning) { let containerView = transitionContext.containerView() let fromVC = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) let toVC = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey) let toView = transitionContext.viewForKey(UITransitionContextToViewKey) //toView?.frame = containerView.frame containerView.addSubview(toView!) toView?.layer.transform = CATransform3DIdentity toView?.alpha = 0 fromView?.layer.transform = CATransform3DMakeTranslation(-188, 0, 0) if self.presenting { UIView.animateWithDuration(1.0, animations: { () -> Void in // fromView?.layer.transform = CATransform3DMakeTranslation(-160, 0, 0) // fromView?.layer.transform = CATransform3DMakeRotation(CGFloat(M_PI_2), 10, 0, 10) fromView?.layer.transform = CATransform3DRotate(CATransform3DMakeTranslation(-188, 0, 0), CGFloat(M_PI_2), 0, 10, 0) toView?.alpha = 1.0 }, completion: { (finished) -> Void in fromView?.layer.transform = CATransform3DIdentity transitionContext.completeTransition(true) }) // if self.presenting { // fromView?.addAnimation(presenting) // UIView.animateWithDuration(1.0, animations: { () -> Void in // toView?.alpha = 1.0 // }, completion: { (finished) -> Void in // transitionContext.completeTransition(true) // }) // UIView.animateWithDuration(transitionDuration(transitionContext), animations: { () -> Void in // var trans = CGAffineTransformMake(0.1, CGFloat(M_PI_2), CGFloat(M_PI_2), 0.1, -width/2, height/2) // var trans1 = CGAffineTransformMakeScale(0.1, 0.1) // var trans2 = CGAffineTransformMakeRotation(CGFloat(M_PI_2)) // var trans3 = CGAffineTransformMakeTranslation(-width/2, height/2) // fromView?.transform = trans2 // fromView?.alpha = 0 // toView?.alpha = 1 // }) { (finished) -> Void in // if finished { // fromView?.transform = CGAffineTransformIdentity // transitionContext.completeTransition(true) // } // } // } }


【文件预览】:
transition
----transitionTests()
--------Info.plist(741B)
--------transitionTests.swift(902B)
----.DS_Store(6KB)
----transition()
--------ViewController.swift(1KB)
--------category.swift(2KB)
--------Base.lproj()
--------toViewController.swift(923B)
--------AppDelegate.swift(2KB)
--------animator.swift(3KB)
--------Images.xcassets()
--------Info.plist(1KB)
----transition.xcodeproj()
--------project.xcworkspace()
--------project.pbxproj(16KB)
--------xcuserdata()

网友评论

  • 功能太简单,太简单呀