成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

iPhone開發(fā)創(chuàng)建連續(xù)動畫案例

移動開發(fā) iOS
本文介紹的是iPhone開發(fā)創(chuàng)建連續(xù)動畫案例,主要介紹了iphone開發(fā)中動畫的作用,來看詳細內(nèi)容。

iPhone開發(fā)創(chuàng)建連續(xù)動畫案例是本文要介紹的內(nèi)容,主要詳細介紹了在iphone開發(fā)中連續(xù)動畫的實現(xiàn)。來看詳細內(nèi)容。在iphone開發(fā)中,我們有些時候需要創(chuàng)建連續(xù)的動畫效果,使用戶體驗更好。

連續(xù)動畫就是一段動畫運行完畢后調(diào)用另一段動畫,一定要保證兩段動畫沒有重疊,本文不打算使用CAKeyframeAnimation建立連續(xù)的動畫塊,雖然使用CAKeyframeAnimation更簡單(在其他的博文中實現(xiàn)此方法)

大概有兩種方法可以選擇:

1.增加延遲以便在***段動畫結(jié)束之后在啟動第二段動畫([performSelector:withObject:afterDelay:])

2.指定動畫委托回調(diào)(animationDidStop:finished:context:)

從編程的角度來說就更容易,下面我們將擴展類UIView的方法,通過類別引入一個新的方法----commitModalAnimations.調(diào)用此方法而不是調(diào)用commitAnimations方法,它會建立一個新的runloop,該循環(huán)只有在動畫結(jié)束的時候才會停止。

這樣確保了commitModalAnimations方法只有在動畫結(jié)束才將控制權(quán)返還給調(diào)用方法,利用此擴展方法可以將動畫塊按順序放進代碼中,不必做任何其他的修改就能避免動畫的重疊現(xiàn)象。

代碼如下:

  1. @interface UIView (ModalAnimationHelper)  
  2. + (void) commitModalAnimations;  
  3. @end  
  4. @interface UIViewDelegate : NSObject  
  5. {  
  6. CFRunLoopRef currentLoop;  
  7. }  
  8. @end  
  9. @implementation UIViewDelegate  
  10. -(id) initWithRunLoop: (CFRunLoopRef)runLoop   
  11. {  
  12. if (self = [super init]) currentLoop = runLoop;  
  13. return self;  
  14. }  
  15. (void) animationFinished: (id) sender  
  16. {  
  17. CFRunLoopStop(currentLoop);  
  18. }  
  19. @end  
  20. @implementation UIView (ModalAnimationHelper)  
  21. + (void) commitModalAnimations  
  22. {  
  23. CFRunLoopRef currentLoop = CFRunLoopGetCurrent();  
  24. UIViewDelegate *uivdelegate = [[UIViewDelegate alloc] initWithRunLoop:currentLoop];  
  25. [UIView setAnimationDelegate:uivdelegate];  
  26. [UIView setAnimationDidStopSelector:@selector(animationFinished:)];  
  27. [UIView commitAnimations];  
  28. CFRunLoopRun();  
  29. [uivdelegate release];  
  30. }  
  31. @end 

使用:

  1. [self.view viewWithTag:101].alpha = 1.0f;  
  2. // Bounce to 115% of the normal size  
  3. [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];  
  4. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
  5. [UIView setAnimationDuration:0.4f];  
  6. [self.view viewWithTag:101].transform = CGAffineTransformMakeScale(1.15f, 1.15f);  
  7. [UIView commitModalAnimations];  
  8. // Return back to 100%  
  9. [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];  
  10. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
  11. [UIView setAnimationDuration:0.3f];  
  12. [self.view viewWithTag:101].transform = CGAffineTransformMakeScale(1.0f, 1.0f);  
  13. [UIView commitModalAnimations];  
  14. // Pause for a second and appreciate the presentation  
  15. [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];  
  16. // Slowly zoom back down and hide the view  
  17. [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];  
  18. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
  19. [UIView setAnimationDuration:1.0f];  
  20. [self.view viewWithTag:101].transform = CGAffineTransformMakeScale(0.01f, 0.01f);  
  21. [UIView commitModalAnimations]; 

小結(jié):iPhone開發(fā)創(chuàng)建連續(xù)動畫案例的內(nèi)容介紹完了,希望本文對你有所幫助!

責任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2009-08-28 17:51:40

iPhone多視圖開發(fā)

2011-08-15 15:44:46

iPhone開發(fā)PDF

2011-08-18 16:24:44

iPhone開發(fā)圖片

2011-07-25 17:13:31

iPhone 圖形 動畫

2011-08-15 13:50:06

IPhone開發(fā)UIView動畫

2011-08-12 14:04:53

iPhone動畫

2011-08-09 14:54:29

iPhoneNSDateanotherDate

2011-08-15 18:02:32

iPhone開發(fā)表視圖

2011-08-16 15:48:37

iPhone開發(fā)抓圖程序

2011-08-19 11:10:31

iPhone應(yīng)用

2011-08-19 10:13:05

iPhone開發(fā)

2011-07-08 10:15:15

IPhone 動畫

2011-08-12 11:31:46

iPhoneUIView動畫

2011-08-16 18:13:42

IPhone開發(fā)UIView動畫

2011-07-29 14:55:25

iPhone開發(fā) 動畫過渡

2011-08-17 16:12:20

iPhone應(yīng)用程序

2011-08-18 15:24:40

iPhone國際化

2011-08-10 14:40:23

iPhone動畫

2011-08-17 16:23:31

iPhone開發(fā)UIViewContr

2011-08-17 16:29:12

iPhone開發(fā)UIButton
點贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 亚洲自拍偷拍免费视频 | 欧美一区视频在线 | 久草中文网 | 国产精品久久久久不卡 | 中国美女av | 国产成人精品久久二区二区 | 久久精品视频网站 | 亚洲精品久久久久久国产精华液 | 国产成人亚洲精品 | 精品一区二区久久久久久久网精 | 日韩视频在线一区 | 久在线视频播放免费视频 | 九九热精品视频 | 久久天天综合 | 久久久精品网 | 99精品欧美一区二区蜜桃免费 | 激情综合五月天 | 91精品久久久久久久久 | 久久精品久久精品久久精品 | 中文字幕第一页在线 | 日韩视频一区二区 | av手机免费在线观看 | 91视视频在线观看入口直接观看 | 亚洲精品一区中文字幕乱码 | 伊人久久综合影院 | 狠狠操狠狠干 | 欧美精品一区二区三区在线播放 | 毛片久久久 | 亚洲一区二区中文字幕 | 无人区国产成人久久三区 | 国产精品99久久久久久动医院 | 香蕉久久av | 性高湖久久久久久久久aaaaa | 久久一区二区精品 | 久久精品日产第一区二区三区 | 欧美中文在线 | 91精品久久久久久久久久入口 | 国产精品久久久久久久久久久新郎 | 国产精品久久 | 久久av一区 | 国产精品国产a级 |