ios开发核心动画五:转场动画
#import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *imageV; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; } static int _i = 1; -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { //转场代码与转场动画必须得在同一个方法当中. //转场代码 // _i++; // if (_i == 4) { // _i = 1; // } // // NSString *imageName = [NSString stringWithFormat:@"%d",_i]; // self.imageV.image = [UIImage imageNamed:imageName]; // // // //添加转场动画 // CATransition *anim = [CATransition animation]; // anim.duration = 1; // //设置转场的类型 // anim