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動畫各種表現方式 參考文檔的內容介紹完了,希望本文對你有所協助!