詳解iPhone中UIView動畫各種表現方式 參考文檔 (下)

來源:互聯網
上載者:User

iPhone應用之UIView動畫實現效果是本文要介紹的內容,主要是來介紹UIView動畫的各種表現方式,繼續上文詳解iPhone中UIView動畫各種表現方式 參考文檔上)開始介紹,我們先來看詳細內容。

setAnimationDuration:

設定動畫塊中的動畫期間用秒)

 
  1. + (void)setAnimationDuration:(NSTimeInterval)duration 

參數

duration

一段動畫持續的時間。

討論

這個方法在動畫塊外沒有效果。使用beginAnimations:context: 類方法來開始一個動畫塊並用commitAnimations類方法來結束一個動畫塊。預設值是0.2。

setAnimationRepeatAutoreverses:

設定動畫塊中的動畫效果是否自動重複播放。

 
  1. + (void)setAnimationRepeatAutoreverses:(BOOL)repeatAutoreverses 

參數

repeatAutoreverses

如果動畫自動重複就是YES否則就是NO。

討論

自動重複是當動畫向前播放結束後再重頭開始播放。使用setAnimationRepeatCount: 類方法來指定動畫自動重播的時間。如果重複數為0或者在動畫塊外那將沒有任何效果。使用beginAnimations:context:類方法來開始一個動畫塊並用commitAnimations方法來結束一個動畫塊。預設值是NO。

setAnimationRepeatCount:

設定動畫在動畫模組中的重複次數

 
  1. + (void)setAnimationRepeatCount:(float)repeatCount 

參數

repeatCount

動畫重複的次數,這個值可以是分數。

討論

這個屬性在動畫塊外沒有任何作用。使用beginAnimations:context:類方法來開始一個動畫塊並用commitAnimations類方法來結束。預設動畫不迴圈。

setAnimationsEnabled:

設定是否啟用動畫

 
  1. + (void)setAnimationsEnabled:(BOOL)enabled 

參數

enabled

如果是YES那就啟用動畫;否則就是NO

討論

當動畫參數沒有被啟用那麼動畫屬性的改變將被忽略。預設動畫是被啟用的。

setAnimationStartDate:

設定在動畫塊內部動畫屬性改變的開始時間

 
  1. + (void)setAnimationStartDate:(NSDate *)startTime 

參數

startTime

一個開始動畫的時間

討論

使用beginAnimations:context:類方法來開始一個動畫塊並用commitAnimations類方法來結束動畫塊。預設的開始時間值由CFAbsoluteTimeGetCurrent方法來返回。

setAnimationTransition:forView:cache:

在動畫塊中為視圖設定過渡

 
  1. + (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache 

參數

transition

把一個過渡效果應用到視圖中。可能的值定義在UIViewAnimationTransition中。

view

需要過渡的視圖對象。

cache

如果是YES,那麼在開始和結束圖片視圖渲染一次並在動畫中建立幀;否則,視圖將會在每一幀都渲染。例如緩衝,你不需要在視圖轉變中不停的更新,你只需要等到轉換完成再去更新視圖。

討論

如果你想要在轉變過程中改變視圖的外貌。舉個例子,檔案從一個視圖到另一個視圖,然後使用一個UIView子類的[內容] 檢視,如下:

 
  1. Begin an animation block.  
  2.  
  3. Set the transition on the container view.  
  4.  
  5. Remove the subview from the container view.  
  6.  
  7. Add the new subview to the container view.  
  8.  
  9. Commit the animation block. 

1、開始一個動畫塊。

2、在[內容] 檢視中設定轉換。

3、在[內容] 檢視中移除子視圖。

4、在[內容] 檢視中添加子視圖。

5、結束動畫塊。

setAnimationWillStartSelector:

當動畫開始時發送一條訊息到動畫代理

 
  1. + (void)setAnimationWillStartSelector:(SEL)selector 

參數

selector

在動畫開始前向動畫代理髮送訊息。預設值是NULL。這個selector必須由和beginAnimations:context: 方法相同的參數,一個任選的程式標識和內容。這些參數都可以是nil。

討論

這個方法在動畫塊外沒有任何作用。使用beginAnimations:context:類方法來開始一個動畫塊並用commitAnimations類方法來結束。

小結:詳解iPhoneUIView動畫各種表現方式 參考文檔的內容介紹完了,希望本文對你有所協助!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.