詳解iPhone中UIView動畫各種表現方式 參考文檔 (下)
iPhone應用之UIView動畫實現效果是本文要介紹的內容,主要是來介紹UIView動畫的各種表現方式,繼續上文詳解iPhone中UIView動畫各種表現方式 參考文檔(上)開始介紹,我們先來看詳細內容。
setAnimationDuration:
設置動畫塊中的動畫持續時間(用秒)
- + (void)setAnimationDuration:(NSTimeInterval)duration
參數
duration
一段動畫持續的時間。
討論
這個方法在動畫塊外沒有效果。使用beginAnimations:context: 類方法來開始一個動畫塊并用commitAnimations類方法來結束一個動畫塊。默認值是0.2。
setAnimationRepeatAutoreverses:
設置動畫塊中的動畫效果是否自動重復播放。
- + (void)setAnimationRepeatAutoreverses:(BOOL)repeatAutoreverses
參數
repeatAutoreverses
如果動畫自動重復就是YES否則就是NO。
討論
自動重復是當動畫向前播放結束後再重頭開始播放。使用setAnimationRepeatCount: 類方法來指定動畫自動重播的時間。如果重復數為0或者在動畫塊外那將沒有任何效果。使用beginAnimations:context:類方法來開始一個動畫塊并用commitAnimations方法來結束一個動畫塊。默認值是NO。
setAnimationRepeatCount:
設置動畫在動畫模塊中的重復次數
- + (void)setAnimationRepeatCount:(float)repeatCount
參數
repeatCount
動畫重復的次數,這個值可以是分數。
討論
這個屬性在動畫塊外沒有任何作用。使用beginAnimations:context:類方法來開始一個動畫塊并用commitAnimations類方法來結束。默認動畫不循環。
setAnimationsEnabled:
設置是否激活動畫
- + (void)setAnimationsEnabled:(BOOL)enabled
參數
enabled
如果是YES那就激活動畫;否則就是NO
討論
當動畫參數沒有被激活那么動畫屬性的改變將被忽略。默認動畫是被激活的。
setAnimationStartDate:
設置在動畫塊內部動畫屬性改變的開始時間
- + (void)setAnimationStartDate:(NSDate *)startTime
參數
startTime
一個開始動畫的時間
討論
使用beginAnimations:context:類方法來開始一個動畫塊并用commitAnimations類方法來結束動畫塊。默認的開始時間值由CFAbsoluteTimeGetCurrent方法來返回。
setAnimationTransition:forView:cache:
在動畫塊中為視圖設置過渡
- + (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache
參數
transition
把一個過渡效果應用到視圖中。可能的值定義在UIViewAnimationTransition中。
view
需要過渡的視圖對象。
cache
如果是YES,那么在開始和結束圖片視圖渲染一次并在動畫中創建幀;否則,視圖將會在每一幀都渲染。例如緩存,你不需要在視圖轉變中不停的更新,你只需要等到轉換完成再去更新視圖。
討論
如果你想要在轉變過程中改變視圖的外貌。舉個例子,文件從一個視圖到另一個視圖,然後使用一個UIView子類的容器視圖,如下:
- Begin an animation block.
- Set the transition on the container view.
- Remove the subview from the container view.
- Add the new subview to the container view.
- Commit the animation block.
1、開始一個動畫塊。
2、在容器視圖中設置轉換。
3、在容器視圖中移除子視圖。
4、在容器視圖中添加子視圖。
5、結束動畫塊。
setAnimationWillStartSelector:
當動畫開始時發送一條消息到動畫代理
- + (void)setAnimationWillStartSelector:(SEL)selector
參數
selector
在動畫開始前向動畫代理發送消息。默認值是NULL。這個selector必須由和beginAnimations:context: 方法相同的參數,一個任選的程序標識和內容。這些參數都可以是nil。
討論
這個方法在動畫塊外沒有任何作用。使用beginAnimations:context:類方法來開始一個動畫塊并用commitAnimations類方法來結束。
小結:詳解iPhone中UIView動畫各種表現方式 參考文檔的內容介紹完了,希望本文對你有所幫助!