转场动画 CATransition: CAAnimation的子类 , 用来做转场动画, 能够为layer层提供移除屏幕和移入屏幕的动画效果
动画属性
1.1 type: 动画的过度效果
1.2 subType: 动画的过度方向
1.3 startProgress: 动画起点(在整体动画的百分比上)
1.4 endProgress: 动画终点(在整体动画的百分比上)type属性的值:
具体实现实例:
#import "ThreeViewController.h"
@interface ThreeViewController ()
//设置属性
@property (strong, nonatomic) UIView *myView;
@end
@implementation ThreeViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.myView = [[UIView alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height-64)];
self.myView.backgroundColor = [UIColor colorWithRed:1.000 green:0.678 blue:0.736 alpha:1.000];
[self.view addSubview:self.myView];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
#pragma mark ------ CATransition -------
//1. 创建对象
CATransition *transition = [CATransition animation];
//2. 动画效果
//@"cube" @"oglFlip" @"pageUnCurl" 上面附图给出type的值
transition.type = @"cube";
//3. 动画的开始位置0 ~ 1(按屏幕比例划分)
transition.startProgress = 0;
//4. 动画的结束位置0 ~ 1
transition.endProgress = 1;
//5. 动画重复次数
transition.repeatCount = 3;
//6. 动画的持续时间
transition.duration = 3;
//7. 动画的方向
transition.subtype = kCATransitionFromLeft;
//8. 添加到layer层上
[self.myView.layer addAnimation:transition forKey:@"transitiong"];
}
@end```