小胖說事5------iOS CATransition的用法
來源:程序員人生 發布時間:2015-06-27 08:35:49 閱讀次數:2803次
CATransition的type屬性
1.#define定義的常量
kCATransitionFade 交叉淡化過渡
kCATransitionMoveIn 新視圖移到舊視圖上面
kCATransitionPush 新視圖把舊視圖推出去
kCATransitionReveal 將舊視圖移開,顯示下面的新視圖
2.用字符串表示
pageCurl 向上翻1頁
pageUnCurl 向下翻1頁
rippleEffect 滴水效果
suckEffect 收縮效果,如1塊布被抽走
cube 立方體效果
oglFlip 上下翻轉效果
- (void)MyCAnimation1 {
CATransition *animation = [CATransition animation];
//動畫時間
animation.duration = 1.0f;
//display mode, slow at beginning and end
animation.timingFunction = UIViewAnimationCurveEaseInOut;
//過渡效果
animation.type = kCATransitionMoveIn;
//過渡方向
animation.subtype = kCATransitionFromTop;
//添加動畫
[imageView.layer addAnimation:animation forKey:nil];
}
- (void)MyCAnimation2 {
CATransition *animation = [CATransition animation];
//動畫時間
animation.duration = 1.0f;
//display mode, slow at beginning and end
animation.timingFunction = UIViewAnimationCurveEaseInOut;
//在動畫履行完時是不是被移除
animation.removedOnCompletion = NO;
//過渡效果
animation.type = @"pageCurl";
//過渡方向
animation.subtype = kCATransitionFromRight;
//暫時不知,感覺與Progress1起用的,如果不加,Progress好像沒有效果
animation.fillMode = kCAFillModeForwards;
//動畫停止(在整體動畫的百分比).
animation.endProgress = 0.7;
[imageView.layer addAnimation:animation forKey:nil];
}
- (void)MyCAnimation3 {
CATransition *animation = [CATransition animation];
//動畫時間
animation.duration = 1.0f;
//display mode, slow at beginning and end
animation.timingFunction = UIViewAnimationCurveEaseInOut;
//過渡效果
animation.type = @"pageUnCurl";
//過渡方向
animation.subtype = kCATransitionFromRight;
//暫時不知,感覺與Progress1起用的,如果不加,Progress好像沒有效果
animation.fillMode = kCAFillModeBackwards;
//動畫開始(在整體動畫的百分比).
animation.startProgress = 0.3;
[imageView.layer addAnimation:animation forKey:nil];
}
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈