iOS开动画效果之──实现 pushViewController 默认动画效果

在开发中,视图切换会常常遇到,有时我们不是基于导航控制器的切换,但实际开发中,有时需要做成push效果,下面将如何实现push和pop 默认动画效果代码实例:

一、push默认动画效果

    CATransition *transition = [CATransition animation];

     transition.duration = 0.3f;

     transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

     transition.type = kCATransitionPush;

     transition.subtype = kCATransitionFromRight;

     transition.delegate = self;

     [self.contentView.layer addAnimation:transition forKey:nil];

     [self.contentView addSubview:self.productDetailController.view];

注:self.contentView是工程中的UIView,self.productDetailController是工程中的controller

只需要把两者替换成合适的内容即可用

二、pop默认动画效果

   CATransition *transition = [CATransition animation];

     transition.duration = 0.3f;

     transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

     transition.type = kCATransitionPush;

     transition.subtype = kCATransitionFromLeft;

     transition.delegate = self;

     [self.view.superview.layer addAnimation:transition forKey:nil];

     [self.view removeFromSuperview];

说明:.type 设置了主要的页面切换显示形式

.subtype 设置了页面的旋转  左右上下

上一篇:iOS 转盘动画效果实现


下一篇:iOS启动动画效果实现