iOS页面间跳转动画效果

页面控制器中使用方法:

     ContentViewController  *cotent=[[ ContentViewController alloc ] initWithNibName : @"ContentViewController" bundle : nil ];

    [CATransaction begin];

    CATransition *transition = [CATransitionanimation];

    transition.type = kCATransitionMoveIn;

    transition.subtype = kCATransitionFromBottom;


    transition.duration=0.5f;

    transition.fillMode=kCAFillModeForwards;

    transition.removedOnCompletion=YES;

    

    [[UIApplicationsharedApplication] .keyWindow.layeraddAnimation:transition forKey:@"transition"];

    [[UIApplicationsharedApplicationbeginIgnoringInteractionEvents];

    [CATransactionsetCompletionBlock: ^ {

        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(transition.duration * NSEC_PER_SEC)),dispatch_get_main_queue(), ^ {

            [[UIApplicationsharedApplicationendIgnoringInteractionEvents];

        });

    }];

    

    [selfpresentModalViewController:content animated:NO];

    

    [CATransaction commit];

此处已经可以实现效果了,可以进项目区试试  下面的是各种跳转的type


 一些动画类型:

animation.type = kCATransitionFade;

    

            animation.type = kCATransitionPush;

    

            animation.type = kCATransitionReveal;

  

            animation.type = kCATransitionMoveIn;

      

            animation.type = @"cube";

       

            animation.type = @"suckEffect";

         

            animation.type = @"oglFlip";

         

            animation.type = @"rippleEffect";

         

            animation.type = @"pageCurl";

         

            animation.type = @"pageUnCurl";

        

            animation.type = @"cameraIrisHollowOpen";

          

            animation.type = @"cameraIrisHollowClose";

          

            animation.subtype = kCATransitionFromLeft;

    

            animation.subtype = kCATransitionFromBottom;

       

            animation.subtype = kCATransitionFromRight;

     

            animation.subtype = kCATransitionFromTop;



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) // } // } // } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值