CAAnimtion子类_CATransition动画

转场动画 CATransition: CAAnimation的子类 , 用来做转场动画, 能够为layer层提供移除屏幕和移入屏幕的动画效果
  1. 动画属性
    1.1 type: 动画的过度效果
    1.2 subType: 动画的过度方向
    1.3 startProgress: 动画起点(在整体动画的百分比上)
    1.4 endProgress: 动画终点(在整体动画的百分比上)

  2. type属性的值:

CAAnimtion子类_CATransition动画_第1张图片
Type.png

具体实现实例:

#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 *)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```

你可能感兴趣的:(CAAnimtion子类_CATransition动画)