1.毛玻璃效果 (iOS8之后)?
iOS8之后新加了UIBlurEffect類和UIVisualEffectView類使用起來也很簡單?
UIBlurEffect類設定毛玻璃效果的類型(3中類型)
UIVisualEffectView類在創(chuàng)建時加入UIBlurEffect的類的對象
2.系統(tǒng)自帶的uiview的block塊
一個簡單的圖片視圖的放大然后漸漸消失的動畫最后移除視圖 可以使用嵌套block塊來實現(xiàn)
3.CALayer層的動畫
CABasicAnimation一般用法通過fromValue和toValue來指定開始和結束的值
屬性Autoreverses 當設為YES時,在它到達目的地后滑黔,動畫回到原始的值,代替直接跳轉到開始的值
Duration 動畫的時長? repeatCount 動畫的重復次數(shù)(默認為0)只走一次略荡。
Speed 動畫播放按照默認的速度播放 默認為1.0 如果改變它的值會影響到動畫的持續(xù)時間汛兜。
RemovedOnCompletion 設為YES在指定時間內(nèi)動畫完成后,動畫從層上移除
animationWithKeyPath的值:
transform.scale 縮放?
transform.translation.y 縱向移動
transform.translation.x 橫向移動
opacity 透明度
transform.rotation.z 旋轉
backgroundColor 背景色變化
+(CABasicAnimation *)opacityForever_Animation:(float)time //永久閃爍的動畫
{
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"opacity"];
animation.fromValue=[NSNumber numberWithFloat:1.0];
animation.toValue=[NSNumber numberWithFloat:0.0];
animation.autoreverses=YES;
animation.duration=time;
animation.repeatCount=FLT_MAX;
animation.removedOnCompletion=NO;
animation.fillMode=kCAFillModeForwards;
return animation;
}
+(CABasicAnimation *)opacityTimes_Animation:(float)repeatTimes durTimes:(float)time; //有閃爍次數(shù)的動畫
{
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"opacity"];
animation.fromValue=[NSNumber numberWithFloat:1.0];
animation.toValue=[NSNumber numberWithFloat:0.4];
animation.repeatCount=repeatTimes;
animation.duration=time;
animation.removedOnCompletion=NO;
animation.fillMode=kCAFillModeForwards;
animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
animation.autoreverses=YES;
return? animation;
}
+(CABasicAnimation *)moveX:(float)time X:(NSNumber *)x //橫向移動
{
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
animation.toValue=x;
animation.duration=time;
animation.removedOnCompletion=NO;
animation.fillMode=kCAFillModeForwards;
return animation;
}
+(CABasicAnimation *)moveY:(float)time Y:(NSNumber *)y //縱向移動
{
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
animation.toValue=y;
animation.duration=time;
animation.removedOnCompletion=NO;
animation.fillMode=kCAFillModeForwards;
return animation;
}
+(CABasicAnimation *)scale:(NSNumber *)Multiple orgin:(NSNumber *)orginMultiple durTimes:(float)time Rep:(float)repeatTimes //縮放
{
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];
animation.fromValue=orginMultiple;
animation.toValue=Multiple;
animation.duration=time;
animation.autoreverses=YES;
animation.repeatCount=repeatTimes;
animation.removedOnCompletion=NO;
animation.fillMode=kCAFillModeForwards;
return animation;
}
+(CAAnimationGroup *)groupAnimation:(NSArray *)animationAry durTimes:(float)time Rep:(float)repeatTimes //組合動畫
{
CAAnimationGroup *animation=[CAAnimationGroup animation];
animation.animations=animationAry;
animation.duration=time;
animation.repeatCount=repeatTimes;
animation.removedOnCompletion=NO;
animation.fillMode=kCAFillModeForwards;
return animation;
}
+(CAKeyframeAnimation *)keyframeAniamtion:(CGMutablePathRef)path durTimes:(float)time Rep:(float)repeatTimes //路徑動畫
{
CAKeyframeAnimation *animation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.path=path;
animation.removedOnCompletion=NO;
animation.fillMode=kCAFillModeForwards;
animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
animation.autoreverses=NO;
animation.duration=time;
animation.repeatCount=repeatTimes;
return animation;
}
CAKeyFrameAnimation 關鍵幀動畫 values屬性指明整個動畫過程中的關鍵幀點
path和values作用一樣 指定整個動畫經(jīng)過的路徑 當values和path同時指定時漏策,values屬性會被忽略掺喻。
keyTimes 指定一個數(shù)組用來為每一個路徑指定動畫時間如果沒有設置keyTimes,系統(tǒng)默認每一個路徑的時間為:time = duration/(values.count - 1)褂乍,每一個路徑的時間相即硼。如果設置路徑的動畫時間不一致時可以傳入一個數(shù)組 數(shù)組的首尾為0和1 如 animation.keyTimes = @[[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:0.2],[NSNumber numberWithFloat:0.4],[NSNumber numberWithFloat:0.8],[NSNumber numberWithFloat:1.0]];那么第一段動畫時長為(0.2-0.0)* duration谦絮,第二段為(0.4-0.2)*duration 依次計算動畫時長。
timeFunctions用以指定時間函數(shù)性锭,類似與運動的加速度
kCAMediaTimingFunctionLinear//線性
?kCAMediaTimingFunctionEaseIn//淡入
?kCAMediaTimingFunctionEaseOut//淡出
?kCAMediaTimingFunctionEaseInEaseOut//淡入淡出
?kCAMediaTimingFunctionDefault//默認
calculationMode來決定每一個子路徑運動的類型
kCAAnimationLinear//默認叫胖,線性
?kCAAnimationDiscrete//離散草冈,無中間過程,但keyTimes設置的時間依舊生效瓮增,物體跳躍地出現(xiàn)在各個關鍵幀上
?kCAAnimationPaced//平均怎棱,keyTimes跟timeFunctions失效
?kCAAnimationCubic//平均,同上
?kCAAnimationCubicPaced//平均绷跑,同上