iOS layer層的轉場動畫
阿新 • • 發佈:2018-11-21
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屬性值說明