iOS 轉場動畫

來源:互聯網
上載者:User

標籤:c   class   blog   code   tar   http   

 

Inherits from CAAnimation : NSObject
Conforms to NSCoding (CAAnimation)
NSCopying (CAAnimation)
CAAction (CAAnimation)
CAMediaTiming (CAAnimation)
NSObject (NSObject)
Framework /System/Library/Frameworks/QuartzCore.framework
Availability Available in iOS 2.0 and later.
Declared in CAAnimation.h

 

       CATransition類實現層的轉場動畫。你可以從一組預定義的轉換或者通過提供定製的CIFilter執行個體來指定轉場效果。

 

[plain] view plaincopy
  1.   //定義個轉場動畫  
  2. CATransition *animation = [CATransition animation];  
  3. //轉場動畫期間  
  4. animation.duration = 0.2f;  
  5. //計時函數,從頭到尾的流暢度???  
  6. animation.timingFunction=UIViewAnimationCurveEaseInOut;  
  7. //轉場動畫類型  
  8. animation.type = kCATransitionReveal;  
  9. //轉場動畫將去的方向  
  10. animation.subtype = kCATransitionFromBottom;  
  11. //動畫時你需要的實現  
  12. self.tabBarController.tabBar.hidden = YES;  
  13.   //添加動畫 (轉場動畫是添加在層上的動畫)  
  14. self.tabBarController.tabBar.layer addAnimation:animation forKey:@"animation"];  



 

說明:

duration:動畫持續的時間長度。

 

timingFunction:沒明白(誰明白的說明一下吧)

 

type:轉場動畫的類型。如果在一個自訂的轉場動畫中指定的過濾器屬性,此屬性將被忽略。

type共有四種類型:

 

NSString * const kCATransitionFade;//逐漸消失NSString * const kCATransitionMoveIn;//移入NSString * const kCATransitionPush;//平移(暫且這麼稱呼吧)NSString * const kCATransitionReveal;//顯露

 

預設類型為kCATransitionFade。

 

subtype:轉場動畫將要去往的方向。

subtpye有四種類型:

 

NSString * const kCATransitionFromRight;NSString * const kCATransitionFromLeft;NSString * const kCATransitionFromTop;NSString * const kCATransitionFromBottom;

預設方向是nil。

 

 

 

[self.tabBarController.tabBar.layer addAnimation:animation forKey:@"animation"];

轉場動畫是添加給layer的!

 

 

以下幾種轉場動畫調用的蘋果的私人API,注意咯,小心用了之後被蘋果打回來。

 

 

[plain] view plaincopy
  1. switch (btn.tag) {  
  2. case 0:  
  3. animation.type = @"cube";//---立方體  
  4. break;  
  5. case 1:  
  6. animation.type = @"suckEffect";//103 吸走的效果  
  7. break;  
  8. case 2://前後翻轉效果  
  9. animation.type = @"oglFlip";//When subType is "fromLeft" or "fromRight", it‘s the official one.  
  10. break;  
  11. case 3:  
  12. animation.type = @"rippleEffect";//110波紋效果  
  13. break;  
  14. case 4:  
  15. animation.type = @"pageCurl";//101翻頁起來  
  16. break;  
  17. case 5:  
  18. animation.type = @"pageUnCurl";//102翻頁下來  
  19. break;  
  20. case 6:  
  21. animation.type = @"cameraIrisHollowOpen ";//107//鏡頭開  
  22. break;  
  23. case 7:  
  24. animation.type = @"cameraIrisHollowClose ";//106鏡頭關  
  25. break;  
  26. default:  
  27. break;  
  28. }  



 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.