今天周末也沒有工作要去加班正好可以好好地整理CATransition動畫屬性的講解和應用,以及UIView翻頁的實例,簡單上手。
TransitionAnimation
-
duration
設置動畫時間
-
type
設置運動類型
1浅辙、公有API的Type
Fade, 淡入淡出
Push, 推擠
Reveal, 揭開
MoveIn, 覆蓋
2裕菠、私有API的Type
Cube, 立方體
SuckEffect, 吮吸
OglFlip, 翻轉
RippleEffect, 波紋
PageCurl, 翻頁
PageUnCurl, 反翻頁
CameraIrisHollowOpen, 開鏡頭
CameraIrisHollowClose, 關鏡頭
3删顶、UIView翻頁Type
CurlDown, 下翻頁
CurlUp, 上翻頁
FlipFromLeft, 左翻轉
FlipFromRight, 右翻轉
- subtype
設置運動方向
kCATransitionFromLeft
kCATransitionFromBottom
kCATransitionFromRight
kCATransitionFromTop
- timingFunction
設置運動軌跡
kCAMediaTimingFunctionLinear 線性,即勻速
kCAMediaTimingFunctionEaseIn 先慢后快
kCAMediaTimingFunctionEaseOut 先快后慢
kCAMediaTimingFunctionEaseInEaseOut 先慢后快再慢
kCAMediaTimingFunctionDefault 實際效果是動畫中間比較快.
4竖螃、使用方法
- (void) transitionWithType:(NSString *)type WithSubtype:(NSString *)subtype ForView:(UIView *)view{
CATransition *animation = [CATransition animation];
animation.duration = 0.7f;
animation.type = type;
if (subtype != nil) {
animation.subtype = subtype;
}
[view.layer addAnimation:animation forKey:@"animation"];
}
5、實例應用逗余,UIView上下左右翻頁
- (void) animationWithView : (UIView *)view WithAnimationTransition : (UIViewAnimationTransition) transition{
[UIView animateWithDuration:1.0f animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:transition forView:view cache:YES];
} completion:^(BOOL finished) {
self.title = @"0000";
}];
}
Dome: github地址