// 实例化一个动画类对象
CATransition *transition1 = [CATransition animation];
transition1.duration = 2;
// 动画速率
transition1.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionLinear];
// 动画的类型
transition1.type = kCATransitionMoveIn;
[parentViewexchangeSubviewAtIndex:0withSubviewAtIndex:1];
// 给视图的层添加动画
[parentView.layer addAnimation:transition1 forKey:@"transition1"];
// 实例化一个动画类对象
CATransition *transition1 = [CATransition animation];
transition1.duration = 2;
// 动画速率
transition1.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionLinear];
// 添加视图层动画的类型
transition1.type = kCATransitionReveal;
// 添加视图层动画的子类型
transition1.subtype = kCATransitionFromTop;
[parentViewexchangeSubviewAtIndex:0withSubviewAtIndex:1];
// 给视图的层添加动画
[parentView.layer addAnimation:transition1 forKey:@"transition1"];
// 实例化一个动画类对象
CATransition *transition1 = [CATransition animation];
transition1.duration = 2;
// 动画速率
transition1.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionLinear];
// 添加视图层动画的类型
transition1.type = @"suckEffect";
// 添加视图层动画的子类型
transition1.subtype = kCATransitionFromTop;
[parentViewexchangeSubviewAtIndex:0withSubviewAtIndex:1];
// 给视图的层添加动画
[parentView.layer addAnimation:transition1 forKey:@"transition1"];
// 实例化一个动画类对象
CATransition *transition1 = [CATransition animation];
transition1.duration = 2;
// 动画速率
transition1.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionLinear];
// 添加视图层动画的类型
transition1.type = @"suckEffect";
transition1.delegate = self;
// 添加视图层动画的子类型
transition1.subtype = kCATransitionFromRight;
[parentViewexchangeSubviewAtIndex:0withSubviewAtIndex:1];
// 给视图的层添加动画
[parentView.layer addAnimation:transition1 forKey:@"transition1"];