layer层的转场动画
直接上代码
- (void)viewDidLoad {
[super viewDidLoad];
self.imageView = [[UIImageView alloc]initWithFrame:self.view.bounds ];
self.imageView.image = [UIImage imageNamed:@"1"];
[self.view addSubview:self.imageView];
UIButton * btn = [[UIButton alloc]initWithFrame:self.view.bounds];
[self.view addSubview:btn];
[btn addTarget:self action:@selector(btnFun) forControlEvents:UIControlEventTouchDown];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)btnFun{
CATransition * ca = [CATransition animation];
ca.type = @"rippleEffect";
ca.duration = 1;
[self.view.layer addAnimation:ca forKey:@"ca"];
self.imageView.image = [UIImage imageNamed:@"2"];
}
属性 | 说明 |
---|---|
type | 动画过渡类型 |
subtype | 动画过度方向 有4种分别是 : fromLeft, fromRight, fromTop and fromBottom。不是所有的type都有subtype |
startProgress | 动画起点(在整体动画的百分比),通常不用设置 |
endProgress | 动画终点(在整体动画的百分比) ,通常不用设置 |
duration | 动画执行时间 |
type属性值说明