動畫 Animation
CALayer是動畫產(chǎn)生的地方樊卓,當將動畫添加到Layer層的時候,不能直接修改layer的屬性
- CoreAnimation 有兩個Layer層次結構 - 模型層樹(model layer tree)和表示層樹(presentation layer tree)
- (instancetype)presentationLayer; - 表示層
- (instancetype)modelLayer; - 模型層
CAAnimation常用的有:
- CABasicAnimation
CABasicAnimation的常用屬性:
- duration 動畫的持續(xù)時間
- beginTime 指定動畫開始的時間阀趴,從開始延遲幾秒的話,設置為CACurrentMediaTime() + 秒數(shù)的方式
- repeatCount 動畫的持續(xù)次數(shù)
- repeatDuration 設置動畫的時間苍匆,在該時間內(nèi)動畫一直執(zhí)行刘急,不計次數(shù)
- autoreverses 動畫結束時是否執(zhí)行逆動畫
- fillMode 動畫在開始和結束時的動畫,默認值是KCAFillModeRemoved
- kCAFillModeForwards 動畫開始之后layer的狀態(tài)將保持在動畫的最后一幀浸踩,而removedOnCompletion的默認屬性值為YES,所以為了使動畫結束之后layer保持結束狀態(tài)叔汁,應將removedOnCompletion設置為NO
- kCAFillModeBackwards 將會立即執(zhí)行動畫的第一幀,無論是否設置beginTime屬性
- kCAFillModeBoth kCAFillModeForwards和kCAFillModeBackwards的組合狀態(tài)
- kCAFillModeRemoved 動畫將在設置的beginTime開始執(zhí)行(若有設置beginTime屬性检碗,則動畫立刻執(zhí)行)据块,而動畫執(zhí)行完成后將會將layer的狀態(tài)恢復原狀
- timingFunction 設置動畫的時間變化
- fromValue 所要改變屬性的起始值
- toValue 所要改變屬性的結束時的值
- byValue 所要改變屬性相同起始值的改變量
- 注:若將removedOnCompletion設置為false狀態(tài),則可能會引起循環(huán)引用的問題
- 原因:由于CAAnimation的delegate使用的Strong類型(強引用類型)
一般創(chuàng)建動畫的時候折剃,會使用到KeyPath的屬性
備注:KeyPath的值
- positon - 移動位置(CGPoint)
- opacitu - 透明度(0-1)
- bounds - 變大與位置(CGRect)
- bounds.size - 由小變大(CGSize)
- backgroundColor - 背景顏色(CGColor)
- cornerRadius - 漸變圓角(任意數(shù)值)
- borderWidth - 改變邊框border的大小(圖形周圍邊框另假,border默認為黑色) (任意數(shù)值)
- contens - 改變layer內(nèi)容(圖片) 若想要達到改變內(nèi)容的動畫效果,則要先在運行之前定義好layer的contents (CGImage)
- transform.scale - 縮放怕犁,放大(0.0-1.0)
- transform.rotation.x - 旋轉動畫(翻轉边篮,沿著X軸)(M_PI * n)
- transform.rotation.y - 旋轉動畫(沿著Y軸)(M_PI * n)
- transform.rotation.z - 旋轉動畫(沿著Z軸)(M_PI * n)
- transform.transiation.x - 橫向移動(沿著X軸)(任意數(shù)值)
- transform.transiation.y - 縱向移動(沿著Y軸)(任意數(shù)值)
旋轉動畫
#pragma mark - 旋轉動畫 -
-(void)setRotateView
{
//1.創(chuàng)建一個View圖層
UIView *animationView = [[UIView alloc]initWithFrame:CGRectMake(10, 50, 70, 70)];
animationView.backgroundColor = [UIColor orangeColor];
//將AnimationView添加到self.view上
[self.view addSubview:animationView];
//2.創(chuàng)建動畫圖層
/**
3.設置keyPath的常用屬性:
transform.rotation.x 圍繞x軸旋轉
transform.rotation.y 圍繞y軸旋轉
transform.rotation.z 圍繞z軸旋轉
*/
CABasicAnimation * basic = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
//4.設置beginTime指定動畫開始的時間,從開始延遲幾秒的話奏甫,設置為CACurrentMediaTime() + 秒數(shù)的方式
basic.beginTime = 0.0;
//5.設置toValue所要改變屬性的結束時的值
basic.toValue = [NSValue valueWithCGPoint:CGPointMake(2*M_PI, 0)];
//6.設置duration動畫的持續(xù)時間
basic.duration = 1.5;
//7.設置repeatCount動畫的持續(xù)次數(shù)
basic.repeatCount = INFINITY;
/**
timingFunction 設置動畫的時間變化
kCAMediaTimingFunctionLinear 在整個動畫時間內(nèi)動畫都是以相同速度來改變 - 勻速運動
kCAMediaTimingFunctionEaseIn 動畫開始慢苟耻,之后加速 - 加速運動
kCAMediaTimingFunctionEaseOut 動畫開始快,之后減速 - 減速運動
kCAMediaTimingFunctionEaseInEaseOut 動畫在開始和結束都慢扶檐,中間時間段內(nèi)速度較快
kCAMediaTimingFunctionDefault 默認動畫
*/
//[basic setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
//8.將動畫添加到圖層
[animationView.layer addAnimation:basic forKey:@"basic"];
}
移動動畫
#pragma mark - 移動動畫 -
-(void)SetMoveAnimationView
{
//1.創(chuàng)建一個View圖層
UIView *animationView = [[UIView alloc]initWithFrame:CGRectMake(10, 120, 70, 70)];
animationView.backgroundColor = [UIColor orangeColor];
//將AnimationView添加到self.view上
[self.view addSubview:animationView];
//2.創(chuàng)建動畫圖層
/**3.position 設置內(nèi)容(eg:UIImage)*/
CABasicAnimation * basic = [CABasicAnimation animationWithKeyPath:@"position"];
//4.fromValue所要改變屬性的起始值
basic.fromValue = [NSValue valueWithCGPoint:CGPointMake(40, 240)];
//5.設置toValue所要改變屬性的結束時的值
basic.toValue = [NSValue valueWithCGPoint:CGPointMake(300, 240)];
//6.設置duration動畫的持續(xù)時間
basic.duration = 2;
//7.設置repeatCount動畫的持續(xù)次數(shù)
basic.repeatCount = INFINITY;
//8.autoreverses動畫結束時是否執(zhí)行逆動畫
basic.autoreverses = YES;
//10.將動畫添加到圖層
[animationView.layer addAnimation:basic forKey:@"basic"];
}
背景顏色變化動畫
#pragma mark - 背景顏色變化動畫 -
-(void)SetBackgroundColorChangeAnimationView
{
//1.創(chuàng)建一個View圖層
UIView *animationView = [[UIView alloc]initWithFrame:CGRectMake(100, 50, 70, 70)];
animationView.backgroundColor = [UIColor orangeColor];
//將AnimationView添加到self.view上
[self.view addSubview:animationView];
//2.創(chuàng)建動畫圖層
//backgroundColor 設置背景顏色的變化
CABasicAnimation * basic = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
//4.fromValue所要改變屬性的起始值
basic.fromValue = (__bridge id _Nullable)([UIColor orangeColor].CGColor);
//5.設置toValue所要改變屬性的結束時的值
basic.toValue = (__bridge id _Nullable)([UIColor lightGrayColor].CGColor);
//6.設置duration動畫的持續(xù)時間
basic.duration = 2;
//7.設置repeatCount動畫的持續(xù)次數(shù)
basic.repeatCount = INFINITY;
//8.autoreverses動畫結束時是否執(zhí)行逆動畫
basic.autoreverses = YES;
//10.將動畫添加到圖層
[animationView.layer addAnimation:basic forKey:@"basic"];
}
內(nèi)容改變動畫
#pragma mark - 內(nèi)容改變動畫 -
-(void)SetContantChangeAnimationView
{
//1.創(chuàng)建一個View圖層
UIImageView *animationView = [[UIImageView alloc]initWithFrame:CGRectMake(200, 50, 70, 70)];
animationView.image = [UIImage imageNamed:@"from"];
[self.view addSubview:animationView];
//2.創(chuàng)建動畫圖層 contents
CABasicAnimation * basic = [CABasicAnimation animationWithKeyPath:@"contents"];
//5.設置toValue所要改變屬性的結束時的值
basic.toValue = (__bridge id _Nullable)([UIImage imageNamed:@"to"].CGImage);
//6.設置duration動畫的持續(xù)時間
basic.duration = 1.5;
//7.設置repeatCount動畫的持續(xù)次數(shù)
basic.repeatCount = INFINITY;
//8.autoreverses動畫結束時是否執(zhí)行逆動畫
basic.autoreverses = YES;
//10.將動畫添加到圖層
[animationView.layer addAnimation:basic forKey:@"basic"];
}
轉換圓角動畫
#pragma mark - 圓角變化動畫 -
-(void)SetRadiusView
{
//1.創(chuàng)建一個View圖層
UIView *animationView = [[UIView alloc]initWithFrame:CGRectMake(10, 310, 70, 70)];
animationView.backgroundColor = [UIColor purpleColor];
[self.view addSubview:animationView];
animationView.layer.masksToBounds = YES;
//2.創(chuàng)建動畫圖層 contents
CABasicAnimation * basic = [CABasicAnimation animationWithKeyPath:@"cornerRadius"];
//5.設置toValue所要改變屬性的結束時的值
basic.toValue = [NSValue valueWithCGPoint:CGPointMake(35, 0)];
//6.設置duration動畫的持續(xù)時間
basic.duration = 2;
//7.設置repeatCount動畫的持續(xù)次數(shù)
basic.repeatCount = INFINITY;
//8.autoreverses動畫結束時是否執(zhí)行逆動畫
basic.autoreverses = YES;
//10.將動畫添加到圖層
[animationView.layer addAnimation:basic forKey:@"basic"];
}
按比例縮放動畫
#pragma mark - 按比例縮放動畫 -
-(void)SetZoomAnimationView
{
//1.創(chuàng)建一個View圖層
UIView *animationView = [[UIView alloc]initWithFrame:CGRectMake(10, 400, 70, 70)];
animationView.backgroundColor = [UIColor purpleColor];
[self.view addSubview:animationView];
//2.創(chuàng)建動畫圖層 contents
/**
transform.scale 按比例縮放 - 0.8
transform.scale.x 縮放寬的比例
transform.scale.y 縮放高的比例
*/
CABasicAnimation * basic = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
basic.fromValue = [NSValue valueWithCGPoint:CGPointMake(0.3, 0)];
//5.設置toValue所要改變屬性的結束時的值
basic.toValue = [NSValue valueWithCGPoint:CGPointMake(1.3, 0)];
//6.設置duration動畫的持續(xù)時間
basic.duration = 2;
//7.設置repeatCount動畫的持續(xù)次數(shù)
basic.repeatCount = INFINITY;
//8.autoreverses動畫結束時是否執(zhí)行逆動畫
basic.autoreverses = YES;
//10.將動畫添加到圖層
[animationView.layer addAnimation:basic forKey:@"basic"];
}
按指定大小進行縮放動畫
#pragma mark - 指定大小縮放 -
-(void)SetAssginZoomView
{
//1.創(chuàng)建一個View圖層
UIView *animationView = [[UIView alloc]initWithFrame:CGRectMake(120, 400, 70, 70)];
animationView.backgroundColor = [UIColor purpleColor];
[self.view addSubview:animationView];
//2.創(chuàng)建動畫圖層 contents
CABasicAnimation * basic = [CABasicAnimation animationWithKeyPath:@"bounds"];
//5.設置toValue所要改變屬性的結束時的值
basic.toValue = [NSValue valueWithCGRect:CGRectMake(800, 500, 90, 30)];
//6.設置duration動畫的持續(xù)時間
basic.duration = 2;
//7.設置repeatCount動畫的持續(xù)次數(shù)
basic.repeatCount = INFINITY;
//8.autoreverses動畫結束時是否執(zhí)行逆動畫
basic.autoreverses = YES;
//10.將動畫添加到圖層
[animationView.layer addAnimation:basic forKey:@"basic"];
}
設置漸變動畫(透明)
#pragma mark - 透明動畫 -
-(void)SetAlphaAnimationView
{
//1.創(chuàng)建一個View圖層
UIView *animationView = [[UIView alloc]initWithFrame:CGRectMake(300, 50, 70, 70)];
animationView.backgroundColor = [UIColor purpleColor];
[self.view addSubview:animationView];
//2.創(chuàng)建動畫圖層 contents
CABasicAnimation * basic = [CABasicAnimation animationWithKeyPath:@"opacity"];
basic.fromValue= [NSValue valueWithCGPoint:CGPointMake(0.3, 0)];
//5.設置toValue所要改變屬性的結束時的值
basic.toValue = [NSValue valueWithCGPoint:CGPointMake(1, 0)];
//6.設置duration動畫的持續(xù)時間
basic.duration = 0.6;
//7.設置repeatCount動畫的持續(xù)次數(shù)
basic.repeatCount = INFINITY;
//8.autoreverses動畫結束時是否執(zhí)行逆動畫
basic.autoreverses = YES;
//10.將動畫添加到圖層
[animationView.layer addAnimation:basic forKey:@"basic"];
}
- CAKeyframeAnimation(關鍵幀動畫)
常用屬性有:
- values 當path=nil的時候才起作用
- keyTimes 一個包含若干NSNumber(浮點型值在0.0~1.0之間)對象值得數(shù)組凶杖,用來區(qū)分動畫的分割時機
- calculationMode 計算模式 主要針對的是每一幀的內(nèi)容來為一個坐標點的情況,也就是對anchorPoint和Position進行的動畫
- kCAAnimationLinear 默認值 自定義控制動畫的時間款筑,可以設置keyTimes,表示當關鍵幀為坐標點的時候智蝠,關鍵幀之間之間直線相連進行插針計算 線性的
- kCAAnimationDiscrete 離散的 不進行插值計算 所有關鍵幀之間逐個兒進行顯示
- kCAAnimationPaced 節(jié)奏動畫,自動計算動畫的運動時間奈梳,使得動畫勻速運行 keyTimes和timingFunctions無效
- kCAAnimationCubic 對關鍵幀為坐標點的關鍵幀進行圓滑曲線相連后進行插值計算 若為曲線形狀杈湾,可通過tensionValues,continuityValues,biasValues來進行調(diào)整自定義,其主要目的是使得運行軌跡變得圓滑攘须,而曲線動畫則要設置timingFunctions
- kCAAnimationCubicPaced 在系統(tǒng)時間內(nèi)運行的距離相同漆撞,keyTimes和timingFunctions無效
- rotationMode 旋轉樣式
- kCAAnimationRotateAuto 根據(jù)路徑自動旋轉
- kCAAnimationRotateAutoReverse 根據(jù)路徑自動翻轉
創(chuàng)建一個例子來實現(xiàn)一下
#pragma mark - CAKeyframeAnimation 核心動畫里面的幀動畫 -
-(void)setCAKeyframeAnimationView
{
//1.創(chuàng)建View
UIView * keyFrameAnimation = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 300)];
keyFrameAnimation.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0-50);
//2.創(chuàng)建貝塞爾曲線
UIBezierPath * bezierPath = [UIBezierPath bezierPathWithOvalInRect:keyFrameAnimation.frame];
//3.再創(chuàng)建一個存放動畫的View
UIView * animationView = [[UIView alloc]initWithFrame:CGRectMake(50, 50, 70, 80)];
animationView.backgroundColor = [UIColor orangeColor];
[self.view addSubview:animationView];
//2.創(chuàng)建幀動畫
CAKeyframeAnimation * keyframe = [CAKeyframeAnimation animationWithKeyPath:@"position"];
keyframe.duration = 5;
keyframe.path = bezierPath.CGPath;
/**
calculationMode的屬性:
kCAAnimationLinear 默認值 自定義控制動畫的時間,可以設置keyTimes,表示當關鍵幀為坐標點的時候,關鍵幀之間之間直線相連進行插針計算 線性的
kCAAnimationDiscrete 離散的 不進行插值計算 所有關鍵幀之間逐個兒進行顯示
kCAAnimationPaced 節(jié)奏動畫浮驳,自動計算動畫的運動時間悍汛,使得動畫勻速運行 keyTimes和timingFunctions無效
kCAAnimationCubic 對關鍵幀為坐標點的關鍵幀進行圓滑曲線相連后進行插值計算 若為曲線形狀,可通過tensionValues,continuityValues,biasValues來進行調(diào)整自定義至会,其主要目的是使得運行軌跡變得圓滑离咐,而曲線動畫則要設置timingFunctions
kCAAnimationCubicPaced 在系統(tǒng)時間內(nèi)運行的距離相同,keyTimes和timingFunctions無效
*/
//calculationMode 計算模式 主要針對的是每一幀的內(nèi)容來為一個坐標點的情況奉件,也就是對anchorPoint和Position進行的動畫
keyframe.calculationMode = kCAAnimationPaced;
keyframe.repeatCount = INFINITY;
//設置旋轉樣式
/**
kCAAnimationRotateAuto 根據(jù)路徑自動旋轉
kCAAnimationRotateAutoReverse 根據(jù)路徑自動翻轉
*/
keyframe.rotationMode = kCAAnimationRotateAutoReverse;
[animationView.layer addAnimation:keyframe forKey:@"keyframe"];
//創(chuàng)建CAShapeLayer
CAShapeLayer * shape = [[CAShapeLayer alloc]init];
shape.strokeColor = [UIColor lightGrayColor].CGColor;
shape.fillColor = [UIColor clearColor].CGColor;
shape.lineWidth = 0.5;
shape.lineJoin = kCALineJoinRound;
shape.lineCap = kCALineCapRound;
shape.path = bezierPath.CGPath;
[self.view.layer addSublayer:shape];
}
- CATransition(轉場動畫)
CATransition的常用屬性有:
- type - 轉場動畫的類型
- kCATransitionFade 淡出效果 (支持方向)
- kCATransitionMoveIn 將新視圖移動到舊視圖上 (支持方向)
- kCATransitionPush 用新視圖來推出舊視圖 (支持方向)
- kCATransitionReveal 將舊視圖移開后再顯示新視圖 (支持方向)
- subtype - 轉場動畫將要去往的方向
- kCATransitionFromRight 從右側轉場
- kCATransitionFromLeft 從左側轉場
- kCATransitionFromTop 從頂部轉場
- kCATransitionFromBottom 從底部轉場
- TimingFunction - 時間函數(shù)
- repeatCount - 重復顯示次數(shù)
創(chuàng)建一個例子來實現(xiàn)上述屬性:
#pragma mark - CATransition 主要用于轉場動畫從一個場景以動畫的形式來過渡到另一個場景 -
-(void)setCATransitionView
{
//1宵蛀、創(chuàng)建顯示效果名稱的label
self.textLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 300)];
self.textLabel.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.width/2.0);
self.textLabel.backgroundColor = [UIColor colorWithRed:88/255.0 green:161/255.0 blue:86/255.0 alpha:1];
self.textLabel.textColor = [UIColor whiteColor];
self.textLabel.font = [UIFont systemFontOfSize:16];
self.textLabel.numberOfLines = 0;
self.textLabel.textAlignment = NSTextAlignmentCenter;
[self.view addSubview:self.textLabel];
//創(chuàng)建按鈕
self.clickButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 180, 40)];
self.clickButton.center = CGPointMake(self.view.frame.size.width/2.0f, self.view.frame.size.height-240);
self.clickButton.backgroundColor = [UIColor blackColor];
[self.clickButton setTitle:@"AnimationChange" forState:UIControlStateNormal];
self.clickButton.titleLabel.textAlignment = NSTextAlignmentCenter;
[self.clickButton addTarget:self action:@selector(ClickButton) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.clickButton];
}
//MARK:點擊按鈕,開始改變轉場動畫效果
-(void)ClickButton
{
//創(chuàng)建轉場動畫圖層
CATransition * transition = [CATransition new];
//設置代理事件
transition.delegate = self;
//設置時間
transition.duration = 1.0;
//設置時間函數(shù)
/**
kCAMediaTimingFunctionLinear
kCAMediaTimingFunctionEaseIn
kCAMediaTimingFunctionEaseOut
kCAMediaTimingFunctionEaseInEaseOut
kCAMediaTimingFunctionDefault 默認
*/
[transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
//設置轉場動畫類型 默認從第一個開始
[transition setType:self.animationArray[_index]];
//設置轉場動畫的方向
/**
kCATransitionFromRight 從右側轉場
kCATransitionFromLeft 從左側轉場
kCATransitionFromTop 從頂部轉場
kCATransitionFromBottom 從底部轉場
*/
transition.subtype = kCATransitionFromLeft;
//設置重復次數(shù)
transition.repeatCount = 1;
//設置鍵值對
[transition setValue:@"transitionAnim" forKey:@"anim"];
//添加到視圖
[self.textLabel.layer addAnimation:transition forKey:@"transition"];
self.textLabel.text = [NSString stringWithFormat:@"This Animation was %@",self.animationArray[_index]];
}
#pragma mark - 實現(xiàn)CAAnimationDelegate方法 -
-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
_index = (_index<self.animationArray.count-1)?_index+1:0;
if(flag)
{
//創(chuàng)建轉場動畫
CATransition * tranAnimation = [CATransition new];
tranAnimation.delegate = self;
tranAnimation.duration = 1.0;
[tranAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
tranAnimation.type = self.animationArray[_index];
tranAnimation.subtype = kCATransitionFromLeft;
tranAnimation.autoreverses = YES;
tranAnimation.repeatCount = 1;
[tranAnimation setValue:@"transitionAnim" forKey:@"anim"];
[self.textLabel.layer addAnimation:tranAnimation forKey:@"transition"];
self.textLabel.text = [NSString stringWithFormat:@"This Animation was %@",self.animationArray[_index]];
}
}
- CASpringAnimation(彈簧動畫)
CASpringAnimation的常用屬性有:
- mass 質(zhì)量县貌,影響圖層運動時的彈簧慣性术陶,質(zhì)量越大,彈簧的拉伸和壓縮的幅度越大煤痕,動畫的速度變慢梧宫,并且波動幅度變大
- stiffness 剛度系數(shù) = 勁度系數(shù)/彈性系數(shù) 當剛度系數(shù)越大的時候,形變所產(chǎn)生的力就越大杭攻,運動就越快
- damping 阻尼系數(shù) 阻止彈簧伸縮的系數(shù)祟敛,阻尼系數(shù)越大疤坝,停止越快
- initialVelocity 初始速率兆解,動畫的初始速度大小速率為正數(shù)時,速度方向與運動方向一致跑揉,當速率為負數(shù)的時候锅睛,速度方向和運動方向相反
- settingDuration 結算時間,返回彈簧動畫到停止時的估算時間历谍,根據(jù)當前的動畫參數(shù)估算通常動畫的時間使用結算時間比較準確
創(chuàng)建一個例子來實現(xiàn)上述屬性
#pragma mark - CASpringAnimation 彈簧動畫-
-(void)setCASpringAnimationView
{
//創(chuàng)建label
self.textLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 200, 50, 30)];
self.textLabel.backgroundColor = [UIColor redColor];
[self.view addSubview:self.textLabel];
//創(chuàng)建彈簧動畫
CASpringAnimation * spring = [CASpringAnimation animationWithKeyPath:@"position.x"];
spring.damping = 5;
spring.stiffness = 100;
spring.mass = 1;
spring.initialVelocity = 0;
spring.fromValue = [NSValue valueWithCGPoint:CGPointMake(self.textLabel.layer.position.x, 0)];
spring.toValue = [NSValue valueWithCGPoint:CGPointMake(self.textLabel.layer.position.x+100, 0)];
spring.autoreverses = YES;
spring.repeatCount = INFINITY;
[self.textLabel.layer addAnimation:spring forKey:spring.keyPath];
}
備注:
- CABasicAnimation(基礎動畫)和CAKeyframeAnimation(幀動畫)的區(qū)別&聯(lián)系
- CABasicAnimation可以看做是最多只有兩個關鍵幀的CAKeyframeAnimation