常見的轉(zhuǎn)場(chǎng)動(dòng)畫
方案1:
//創(chuàng)建轉(zhuǎn)場(chǎng)動(dòng)畫對(duì)象
CATransition *transition = [[CATransition alloc]init];
/* The name of the transition. Current legal transition types include
* `fade', `moveIn', `push' and `reveal'. Defaults to `fade'. */
/**
* 1.#define定義的常量
kCATransitionFade 交叉淡化過渡 默許
kCATransitionMoveIn 新視圖移到舊視圖上面,覆蓋原圖
kCATransitionPush 新視圖把舊視圖推出去 ,推出
kCATransitionReveal 將舊視圖移開,顯示下面的新視圖 ,從底部顯示
2.用字符串表示
pageCurl 向上翻1頁(yè)
pageUnCurl 向下翻1頁(yè)
rippleEffect 滴水效果
suckEffect 收縮效果,如1塊布被抽走
cube 立方體效果
oglFlip 上下翻轉(zhuǎn)效果
注意:
還有很多私有API效果,使用的時(shí)候要謹(jǐn)慎,可能會(huì)致使app審核不被通過(悲劇啊,為啥有卻不讓用啊!好東西不應(yīng)當(dāng)被置之不理!)
fade //交叉淡化過渡(不支持過渡方向)
push //新視圖把舊視圖推出去
moveIn //新視圖移到舊視圖上面
reveal //將舊視圖移開,顯示下面的新視圖
cube //立方體翻滾效果
oglFlip //上下左右翻轉(zhuǎn)效果
suckEffect //收縮效果,如1塊布被抽走(不支持過渡方向)
rippleEffect //滴水效果(不支持過渡方向)
pageCurl //向上翻頁(yè)效果
pageUnCurl //向下翻頁(yè)效果
cameraIrisHollowOpen //相機(jī)鏡頭打開效果(不支持過渡方向)
cameraIrisHollowClose //相機(jī)鏡頭關(guān)上效果(不支持過渡方向)
*/
//設(shè)置動(dòng)畫類型,注意對(duì)蘋果官方?jīng)]有公然的動(dòng)畫類型智能使用字符串,并沒有對(duì)應(yīng)的常量意義
// transaction.type=@"pageCurl";//控制圖片的滑動(dòng)類型
if (isNext == YES) {
transition.type = @"pageCurl";
transition.subtype = kCATransitionFromRight;
} else {
transition.type = @"cube";
transition.subtype = kCATransitionFromLeft;
}
//設(shè)置動(dòng)畫時(shí)長(zhǎng),默許為0
transition.duration=1.0;
/* The amount of progress through to the transition at which to begin
* and end execution. Legal values are numbers in the range [0,1].
* `endProgress' must be greater than or equal to `startProgress'.
* Default values are 0 and 1 respectively. */
//動(dòng)畫開始的進(jìn)度
// transaction.startProgress=0.1;
//動(dòng)畫結(jié)束的進(jìn)度,,,結(jié)束的進(jìn)度必須大于開始的進(jìn)度
// transaction.endProgress=0.5;
//動(dòng)畫的速度
// transaction.speed=100.0;
//設(shè)置轉(zhuǎn)場(chǎng)后的新視圖添加轉(zhuǎn)場(chǎng)動(dòng)畫
self.imageView.image=[self transitionImage:isNext];
//添加動(dòng)畫效果
[self.imageView.layer addAnimation:transition forKey:@"Animation"];
畫方案2:
可以直接調(diào)用下面這個(gè)函數(shù)
[UIView transitionFromView:view2 toView:view1 duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
//這個(gè)api 原理 :
// 1:[fromvalue.superview addSubview:tovalue];
// 2:[fromvalue removeFromSuperview];
// NSLog(@"fromvalue-->%@",fromvalue.superview);
// NSLog(@"tovalue-->%@",tovalue.superview);
}];