前言:今天有空把轉(zhuǎn)場(chǎng)動(dòng)畫的筆記整理了一下摇零,不廢話直接上代碼
pragma mark -- 1
- 我們首先在stroyboard中拖一個(gè)UIImageView,自己找?guī)讖垐D片放到項(xiàng)目中滔岳。
- 將UIImageView拖出來
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
- 我們直接在點(diǎn)擊屏幕的方法里來實(shí)現(xiàn)轉(zhuǎn)場(chǎng)動(dòng)畫
static int _number = 1;
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//轉(zhuǎn)場(chǎng)代碼
_number++;
//這里是簡(jiǎn)單判斷
if (_number > 3) {
_number = 1;
}
//我一共是設(shè)置了三張圖片切換,拼接了一下字符串
NSString *imageName = [NSString stringWithFormat:@"%d",_number ];
self.imageView.image = [UIImage imageNamed:imageName];
//轉(zhuǎn)場(chǎng)動(dòng)畫代碼
//1.創(chuàng)建動(dòng)畫
CATransition *animation = [CATransition animation];
//2.設(shè)置轉(zhuǎn)場(chǎng)類型
animation.type = @"suckEffect";
//轉(zhuǎn)場(chǎng)時(shí)間
animation.duration = 0.8;
//設(shè)置轉(zhuǎn)場(chǎng)方向
animation.subtype = kCATransitionFromBottom;
//設(shè)置動(dòng)畫的起始點(diǎn)
animation.startProgress = 0.5;//范圍是0-1
//設(shè)置動(dòng)畫的結(jié)束點(diǎn)
animation.endProgress = 0.8;
//3.添加動(dòng)畫
[self.imageView.layer addAnimation:animation forKey:nil];
//代碼實(shí)現(xiàn)部分就是這些了
}
pragma mark -- 2
1.@"cube":上下旋轉(zhuǎn)的立體轉(zhuǎn)場(chǎng)
2.@"push":推送轉(zhuǎn)場(chǎng)
3.@"fade":交叉淡化過渡
4.@"moveIn":新的移到舊的之上
5.@"reveal":將舊的移開挽牢,顯示新的
6.@"oglFlip":上下左右翻轉(zhuǎn)效果
7.@"suckEffect":收縮效果(無(wú)方向)
8.@"pageCurl":向上翻頁(yè)效果
9.@"pageUnCurl":向下翻頁(yè)效果
10.@"cameraIrisHollowOpen":相機(jī)鏡頭打開效果(無(wú)方向)
11.@"cameraIrisHollowClose":相機(jī)鏡頭關(guān)閉效果(無(wú)方向)
12.@"rippleEffect":水滴效果(無(wú)方向)
######注意:轉(zhuǎn)場(chǎng)代碼和轉(zhuǎn)場(chǎng)動(dòng)畫代碼都必須放在一個(gè)方法里才行(當(dāng)然兩者是沒有順序之分的)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者