参考 https://www.jianshu.com/p/239cf81eb1eb
self.loginBgImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 66, screenW - 20, 300)];
[self.loginBgImageView setImage:[UIImage imageNamed:@"niaoren"]];
[self.view addSubview:self.loginBgImageView];
切换图片的地方
CATransition *transition = [CATransition animation];
transition.duration = 3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.loginBgImageView.layer addAnimation:transition forKey:nil];
[self.loginBgImageView setImage:[UIImage imageNamed:@"lufei"]];
//动画切换的方式
/*1.kCATransitionMoveIn 新的视图把旧的视图掩盖
*2.kCATransitionPush 旧的视图移走,新的视图移进来
*3.kCATransitionFade 逐渐消失,相当于调整透明度,除了这没有方向,其他的都有
*4.kCATransitionReveal 旧的视图移走,显示出新的视图
*/
// animation.type = kCATransitionReveal;
//这类是API引入的,在苹果官网是不会承认的,所以不建议使用
/*1.animation.type = @"cube"; //立方体效果
*2.animation.type = @"suckEffect";//犹如一块布被抽走
*3. animation.type = @"oglFlip"; //上下翻转效果
*4. animation.type = @"rippleEffect"; //滴水效果
*5. animation.type = @"pageCurl"; //向左翻页
*6.animation.type = @"pageUnCurl"; //向下翻页
*7.cameraIrisHollowClose // 关镜头
*8.cameraIrisHollowOpen // 开镜头
*/
控制器跳转
CATransition *transition = [CATransition animation];
transition.duration = 3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
//transition.type = @"cube";
[self.navigationController.view.layer addAnimation:transition forKey:nil];
SecAnimViewController *test = [[SecAnimViewController alloc]init];
test.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:test animated:YES];