一哩俭、UIKit動(dòng)畫
- 第一種寫法是利用屬性,結(jié)合beginAnimations、commitAnimations
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2-50, HEIGHT/2-50, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
//開始動(dòng)畫
[UIView beginAnimations:@"test1" context:nil];
//動(dòng)畫時(shí)長(zhǎng)
[UIView setAnimationDuration:1];
/*
*要進(jìn)行動(dòng)畫設(shè)置的地方
*/
redView.backgroundColor=[UIColor blueColor];
redView.frame=CGRectMake(WIDTH/2-100, HEIGHT/2-100, 200, 200);
redView.alpha=0.5;
//動(dòng)畫結(jié)束
[UIView commitAnimations];
- 第二種寫法也是比較常見(jiàn)的,已經(jīng)對(duì)它進(jìn)行的封裝
//初始化一個(gè)View拼窥,用來(lái)顯示動(dòng)畫
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2-50, HEIGHT/2-50, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
[UIView animateWithDuration:1 //時(shí)長(zhǎng)
delay:0 //延遲時(shí)間
options:UIViewAnimationOptionTransitionFlipFromLeft//動(dòng)畫效果
animations:^{
//動(dòng)畫設(shè)置區(qū)域
redView.backgroundColor=[UIColor blueColor];
redView.frame=CGRectMake(WIDTH/2-100, HEIGHT/2-100, 200, 200);
redView.alpha=0.5;
} completion:^(BOOL finish){
//動(dòng)畫結(jié)束時(shí)調(diào)用
NSLog(@"我結(jié)束了");
}];
關(guān)于動(dòng)畫效果的枚舉如下:
- 常規(guī)動(dòng)畫屬性設(shè)置(可以同時(shí)選擇多個(gè)進(jìn)行設(shè)置)
UIViewAnimationOptionLayoutSubviews:動(dòng)畫過(guò)程中保證子視圖跟隨運(yùn)動(dòng)。
UIViewAnimationOptionAllowUserInteraction:動(dòng)畫過(guò)程中允許用戶交互蹋凝。
UIViewAnimationOptionBeginFromCurrentState:所有視圖從當(dāng)前狀態(tài)開始運(yùn)行鲁纠。
UIViewAnimationOptionRepeat:重復(fù)運(yùn)行動(dòng)畫。
UIViewAnimationOptionAutoreverse :動(dòng)畫運(yùn)行到結(jié)束點(diǎn)后仍然以動(dòng)畫方式回到初始點(diǎn)鳍寂。
UIViewAnimationOptionOverrideInheritedDuration:忽略嵌套動(dòng)畫時(shí)間設(shè)置改含。
UIViewAnimationOptionOverrideInheritedCurve:忽略嵌套動(dòng)畫速度設(shè)置。
UIViewAnimationOptionAllowAnimatedContent:動(dòng)畫過(guò)程中重繪視圖(注意僅僅適用于轉(zhuǎn)場(chǎng)動(dòng)畫)迄汛。
UIViewAnimationOptionShowHideTransitionViews:視圖切換時(shí)直接隱藏舊視圖捍壤、顯示新視圖,而不是將舊視圖從父視圖移除(僅僅適用于轉(zhuǎn)場(chǎng)動(dòng)畫)
UIViewAnimationOptionOverrideInheritedOptions :不繼承父動(dòng)畫設(shè)置或動(dòng)畫類型鞍爱。
- 動(dòng)畫速度控制(可從其中選擇一個(gè)設(shè)置)
UIViewAnimationOptionCurveEaseInOut:動(dòng)畫先緩慢鹃觉,然后逐漸加速。
UIViewAnimationOptionCurveEaseIn :動(dòng)畫逐漸變慢硬霍。
UIViewAnimationOptionCurveEaseOut:動(dòng)畫逐漸加速帜慢。
UIViewAnimationOptionCurveLinear :動(dòng)畫勻速執(zhí)行,默認(rèn)值唯卖。
- 轉(zhuǎn)場(chǎng)類型(僅適用于轉(zhuǎn)場(chǎng)動(dòng)畫設(shè)置粱玲,可以從中選擇一個(gè)進(jìn)行設(shè)置,基本動(dòng)畫拜轨、關(guān)鍵幀動(dòng)畫不需要設(shè)置)
UIViewAnimationOptionTransitionNone:沒(méi)有轉(zhuǎn)場(chǎng)動(dòng)畫效果抽减。
UIViewAnimationOptionTransitionFlipFromLeft :從左側(cè)翻轉(zhuǎn)效果。
UIViewAnimationOptionTransitionFlipFromRight:從右側(cè)翻轉(zhuǎn)效果橄碾。
UIViewAnimationOptionTransitionCurlUp:向后翻頁(yè)的動(dòng)畫過(guò)渡效果卵沉。
UIViewAnimationOptionTransitionCurlDown :向前翻頁(yè)的動(dòng)畫過(guò)渡效果颠锉。
UIViewAnimationOptionTransitionCrossDissolve:舊視圖溶解消失顯示下一個(gè)新視圖的效果。
UIViewAnimationOptionTransitionFlipFromTop :從上方翻轉(zhuǎn)效果史汗。
UIViewAnimationOptionTransitionFlipFromBottom:從底部翻轉(zhuǎn)效果琼掠。
二、CoreAnimation理論知識(shí)
1. Core Animation是直接作用在CALayer上的(并非UIView上)非常強(qiáng)大的跨Mac OS X和iOS平臺(tái)的動(dòng)畫處理API停撞,Core Animation的動(dòng)畫執(zhí)行過(guò)程都是在后臺(tái)操作的瓷蛙,不會(huì)阻塞主線程。CABasicAnimation(基本動(dòng)畫)戈毒、CAKeyframeAnimation(關(guān)鍵幀動(dòng)畫)艰猬、CAAnimationGroup(動(dòng)畫組)、CATransition(轉(zhuǎn)場(chǎng)動(dòng)畫)
使用步驟如下(#import <QuartzCore/QuartzCore.h> ):
首先得有CALayer(因?yàn)镃oreAnimation是作用在CALayer上的)
初始化一個(gè)CAAnimation對(duì)象埋市,并設(shè)置一些動(dòng)畫相關(guān)屬性
通過(guò)調(diào)用CALayer的addAnimation:forKey:方法冠桃,增加CAAnimation對(duì)象到CALayer中,這樣就能開始執(zhí)行動(dòng)畫了
通過(guò)調(diào)用CALayer的removeAnimationForKey:方法可以停止CALayer中的動(dòng)畫
2. CAAnimation中的一些屬性:
duration:動(dòng)畫的持續(xù)時(shí)間
repeatCount:重復(fù)次數(shù)道宅,無(wú)限循環(huán)可以設(shè)置HUGE_VALF或者M(jìn)AXFLOAT
repeatDuration:重復(fù)時(shí)間
removedOnCompletion:默認(rèn)為YES食听,代表動(dòng)畫執(zhí)行完畢后就從圖層上移除,圖形會(huì)恢復(fù)到動(dòng)畫執(zhí)行前的狀態(tài)培己。如果想讓圖層保持顯示動(dòng)畫執(zhí)行后的狀態(tài)碳蛋,那就設(shè)置為NO胚泌,不過(guò)*還要設(shè)置fillMode為kCAFillModeForwards*
beginTime:可以用來(lái)設(shè)置動(dòng)畫延遲執(zhí)行時(shí)間省咨,若想延遲2s,就設(shè)置為CACurrentMediaTime()+2玷室,CACurrentMediaTime()為圖層的當(dāng)前時(shí)間
timingFunction:速度控制函數(shù)零蓉,控制動(dòng)畫運(yùn)行的節(jié)奏
delegate:動(dòng)畫代理
fillMode決定當(dāng)前對(duì)象在非active時(shí)間段的行為。(要想fillMode有效穷缤,最好設(shè)置removedOnCompletion = NO)
kCAFillModeRemoved 這個(gè)是默認(rèn)值敌蜂,也就是說(shuō)當(dāng)動(dòng)畫開始前和動(dòng)畫結(jié)束后,動(dòng)畫對(duì)layer都沒(méi)有影響津肛,動(dòng)畫結(jié)束后章喉,layer會(huì)恢復(fù)到之前的狀態(tài)
kCAFillModeForwards 當(dāng)動(dòng)畫結(jié)束后,layer會(huì)一直保持著動(dòng)畫最后的狀態(tài)
kCAFillModeBackwards 在動(dòng)畫開始前身坐,只需要將動(dòng)畫加入了一個(gè)layer秸脱,layer便立即進(jìn)入動(dòng)畫的初始狀態(tài)并等待動(dòng)畫開始。
kCAFillModeBoth 這個(gè)其實(shí)就是上面兩個(gè)的合成.動(dòng)畫加入后開始之前部蛇,layer便處于動(dòng)畫初始狀態(tài)摊唇,動(dòng)畫結(jié)束后layer保持動(dòng)畫最后的狀態(tài)
CAMediaTimingFunction:速度控制函數(shù)
kCAMediaTimingFunctionLinear(線性):勻速,給你一個(gè)相對(duì)靜態(tài)的感覺(jué)
kCAMediaTimingFunctionEaseIn(漸進(jìn)):動(dòng)畫緩慢進(jìn)入涯鲁,然后加速離開
kCAMediaTimingFunctionEaseOut(漸出):動(dòng)畫全速進(jìn)入巷查,然后減速的到達(dá)目的地
kCAMediaTimingFunctionEaseInEaseOut(漸進(jìn)漸出):動(dòng)畫緩慢的進(jìn)入有序,中間加速,然后減速的到達(dá)目的地岛请。這個(gè)是默認(rèn)的動(dòng)畫行為旭寿。
3. CAAnimation代理方法CAAnimationDelegate
CAAnimation在分類中定義了代理方法。是給NSObject添加的分類崇败,所以任何對(duì)象许师,成為CAAnimation的代理,都可以僚匆。
動(dòng)畫開始的時(shí)候調(diào)用
-(void)animationDidStart:(CAAnimation *)anim;
動(dòng)畫停止的時(shí)候調(diào)用
-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag;
三微渠、CoreAnimation動(dòng)畫實(shí)例
- CABasicAnimation(基本動(dòng)畫)
屬性說(shuō)明:
keyPath :要改變的屬性名稱(傳字符串)
fromValue:keyPath相應(yīng)屬性的初始值
toValue:keyPath相應(yīng)屬性的結(jié)束值
動(dòng)畫過(guò)程說(shuō)明:
隨著動(dòng)畫的進(jìn)行,在長(zhǎng)度為duration的持續(xù)時(shí)間內(nèi)咧擂,keyPath相應(yīng)屬性的值從fromValue漸漸地變?yōu)閠oValue
keyPath內(nèi)容是CALayer的動(dòng)畫Animatable屬性
animationWithKeyPath的值:#define angle2Radian(angle) ((angle)/180.0*M_PI)
transform.rotation.x 圍繞x軸翻轉(zhuǎn) 參數(shù):角度 angle2Radian(4)
transform.rotation.y 圍繞y軸翻轉(zhuǎn) 參數(shù):同上
transform.rotation.z 圍繞z軸翻轉(zhuǎn) 參數(shù):同上
transform.rotation 默認(rèn)圍繞z軸
transform.scale.x x方向縮放 參數(shù):縮放比例 1.5
transform.scale.y y方向縮放 參數(shù):同上
transform.scale.z z方向縮放 參數(shù):同上
transform.scale 所有方向縮放 參數(shù):同上
transform.translation.x x方向移動(dòng) 參數(shù):x軸上的坐標(biāo) 100
transform.translation.y x方向移動(dòng) 參數(shù):y軸上的坐標(biāo)
transform.translation.z x方向移動(dòng) 參數(shù):z軸上的坐標(biāo)
transform.translation 移動(dòng) 參數(shù):移動(dòng)到的點(diǎn) (100逞盆,100)
opacity 透明度 參數(shù):透明度 0.5
backgroundColor 背景顏色 參數(shù):顏色 (id)[[UIColor redColor] CGColor]
cornerRadius 圓角 參數(shù):圓角半徑 5
borderWidth 邊框?qū)挾?參數(shù):邊框?qū)挾?5
bounds 大小 參數(shù):CGRect
contents 內(nèi)容 參數(shù):CGImage
contentsRect 可視內(nèi)容 參數(shù):CGRect 值是0~1之間的小數(shù)
hidden 是否隱藏
position 位置
shadowColor 陰影顏色
shadowOffset 陰影偏移量
shadowOpacity 陰影透明度
shadowRadius 陰影半徑
縮放變化:
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2-50, HEIGHT/2-50, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
CABasicAnimation *pulse = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
pulse.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
pulse.duration = 0.5 + (rand() % 10) * 0.05;
pulse.repeatCount = 1;
pulse.autoreverses = YES;
pulse.fromValue = [NSNumber numberWithFloat:.8];
pulse.toValue = [NSNumber numberWithFloat:1.2];
[redView.layer addAnimation:pulse forKey:nil];
大小變化:
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2-50, HEIGHT/2-50, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"bounds"];
anim.duration = 1.f;
anim.fromValue=[NSValue valueWithCGRect:CGRectMake(WIDTH/2-25, HEIGHT/2-25,50,50)];
anim.toValue = [NSValue valueWithCGRect:CGRectMake(10,10,200,200)];
anim.byValue = [NSValue valueWithCGRect:redView.bounds];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
anim.repeatCount = 1;
anim.autoreverses = YES;
[redView.layer addAnimation:anim forKey:nil];
背景色變化:
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2-50, HEIGHT/2-50, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
anim.duration = 3.f;
anim.toValue = (id)[UIColor greenColor].CGColor;
anim.fromValue = (id)[UIColor redColor].CGColor;
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
anim.repeatCount = CGFLOAT_MAX;
[redView.layer addAnimation:anim forKey:nil];
y軸移動(dòng):
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2-50, HEIGHT/2-50, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
animation.toValue=@150;
animation.duration=2;
animation.removedOnCompletion=NO;
animation.fillMode=kCAFillModeForwards;
[redView.layer addAnimation:animation forKey:nil];
- CAKeyframeAnimation(關(guān)鍵幀動(dòng)畫)
CABasicAnimation只能從一個(gè)數(shù)值(fromValue)變到另一個(gè)數(shù)值(toValue),而CAKeyframeAnimation會(huì)使用一個(gè)NSArray保存這些數(shù)值
屬性說(shuō)明:
values:上述的NSArray對(duì)象松申。里面的元素稱為“關(guān)鍵幀”(keyframe)云芦。動(dòng)畫對(duì)象會(huì)在指定的時(shí)間(duration)內(nèi),依次顯示values數(shù)組中的每一個(gè)關(guān)鍵幀
path:可以設(shè)置一個(gè)CGPathRef贸桶、CGMutablePathRef舅逸,讓圖層按照路徑軌跡移動(dòng)。path只對(duì)CALayer的anchorPoint和position起作用皇筛。如果設(shè)置了path琉历,那么values將被忽略
keyTimes:可以為對(duì)應(yīng)的關(guān)鍵幀指定對(duì)應(yīng)的時(shí)間點(diǎn),其取值范圍為0到1.0水醋,keyTimes中的每一個(gè)時(shí)間值都對(duì)應(yīng)values中的每一幀旗笔。如果沒(méi)有設(shè)置keyTimes,各個(gè)關(guān)鍵幀的時(shí)間是平分的拄踪,CABasicAnimation可看做是只有2個(gè)關(guān)鍵幀的CAKeyframeAnimation
分別使用屬性values及path兩種的效果蝇恶;圍繞的點(diǎn)視圖塊進(jìn)行轉(zhuǎn)動(dòng)效果
values方式:
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2-50, HEIGHT/2-50, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];
animation.keyPath = @"position";
NSValue *value1=[NSValue valueWithCGPoint:CGPointMake(100, 100)];
NSValue *value2=[NSValue valueWithCGPoint:CGPointMake(200, 100)];
NSValue *value3=[NSValue valueWithCGPoint:CGPointMake(200, 200)];
NSValue *value4=[NSValue valueWithCGPoint:CGPointMake(100, 200)];
NSValue *value5=[NSValue valueWithCGPoint:CGPointMake(100, 100)];
animation.values=@[value1,value2,value3,value4,value5];
animation.repeatCount=MAXFLOAT;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
animation.duration = 4.0f;
animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.delegate=self;
[redView.layer addAnimation:animation forKey:nil];
path方式:
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2-50, HEIGHT/2-50, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];
animation.keyPath = @"position";
CGMutablePathRef path=CGPathCreateMutable();
CGPathAddEllipseInRect(path, NULL, CGRectMake(150, 100, 100, 100));
animation.path=path;
CGPathRelease(path);
animation.repeatCount=MAXFLOAT;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
animation.duration = 4.0f;
animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.delegate=self;
[redView.layer addAnimation:animation forKey:nil];
- CAAnimationGroup(動(dòng)畫組)
動(dòng)畫組,是CAAnimation的子類惶桐,可以保存一組動(dòng)畫對(duì)象撮弧,將CAAnimationGroup對(duì)象加入層后,組中所有動(dòng)畫對(duì)象可以同時(shí)并發(fā)運(yùn)行
屬性說(shuō)明:
animations:用來(lái)保存一組動(dòng)畫對(duì)象的NSArray
默認(rèn)情況下姚糊,一組動(dòng)畫對(duì)象是同時(shí)運(yùn)行的贿衍,也可以通過(guò)設(shè)置動(dòng)畫對(duì)象的beginTime屬性來(lái)更改動(dòng)畫的開始時(shí)間
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2-50, HEIGHT/2-50, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
//貝塞爾曲線路徑
UIBezierPath *movePath = [UIBezierPath bezierPath];
[movePath moveToPoint:CGPointMake(10.0, 10.0)];
[movePath addQuadCurveToPoint:CGPointMake(100, 300) controlPoint:CGPointMake(300, 100)];
//關(guān)鍵幀動(dòng)畫(位置)
CAKeyframeAnimation * posAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
posAnim.path = movePath.CGPath;
posAnim.removedOnCompletion = YES;
//縮放動(dòng)畫
CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)];
scaleAnim.removedOnCompletion = YES;
//透明動(dòng)畫
CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
opacityAnim.removedOnCompletion = YES;
//動(dòng)畫組
CAAnimationGroup *animGroup = [CAAnimationGroup animation];
animGroup.animations = [NSArray arrayWithObjects:posAnim, scaleAnim, opacityAnim, nil];
animGroup.duration = 5;
[redView.layer addAnimation:animGroup forKey:nil];
- CATransition(轉(zhuǎn)場(chǎng)動(dòng)畫)
動(dòng)畫屬性:
type:動(dòng)畫過(guò)渡類型
subtype:動(dòng)畫過(guò)渡方向
startProgress:動(dòng)畫起點(diǎn)(在整體動(dòng)畫的百分比)
endProgress:動(dòng)畫終點(diǎn)(在整體動(dòng)畫的百分比)
subtype:動(dòng)畫過(guò)渡方向(默認(rèn)為nil,如果指定了filter,那么該屬性無(wú)效,kCATransitionFromRight,kCATransitionFromLeft,kCATransitionFromTop,kCATransitionFromBottom;分別表示:過(guò)渡從右邊叛拷、左邊舌厨、頂部、底部 開始)
轉(zhuǎn)場(chǎng)動(dòng)畫的類型(NSString *type),還有很多私有API類型
fade : 交叉淡化過(guò)渡
push : 新視圖把舊視圖推出去
moveIn: 新視圖移到舊視圖上面
reveal: 將舊視圖移開,顯示下面的新視圖
cube : 立方體翻滾效果
oglFlip : 上下左右翻轉(zhuǎn)效果
suckEffect : 收縮效果忿薇,如一塊布被抽走
rippleEffect: 水滴效果
pageCurl : 向上翻頁(yè)效果
pageUnCurl : 向下翻頁(yè)效果
cameraIrisHollowOpen : 相機(jī)鏡頭打開效果
cameraIrisHollowClos : 相機(jī)鏡頭關(guān)閉效果
從下往上運(yùn)動(dòng):
//y點(diǎn)就是當(dāng)要運(yùn)動(dòng)后到的Y值
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2-50, HEIGHT/2-50, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
CATransition *animation = [CATransition animation];
animation.duration = 1;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.type = kCATransitionMoveIn;
animation.subtype = kCATransitionFromTop;
//添加動(dòng)畫
[redView.layer addAnimation:animation forKey:nil];
從上往下運(yùn)動(dòng):
//y點(diǎn)就是當(dāng)要運(yùn)動(dòng)后到的Y值
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2-50, HEIGHT/2-50, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
CATransition *animation = [CATransition animation];
animation.duration = 0.4f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromBottom;
//添加動(dòng)畫
[redView.layer addAnimation:animation forKey:nil];
最后附上gitHub地址下載:CoreAnimationDemo