自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iPhone開發(fā)中關(guān)于UIView Animation實(shí)現(xiàn)效果

移動開發(fā) iOS
iPhone開發(fā)中關(guān)于UIView Animation實(shí)現(xiàn)效果是本文要介紹的內(nèi)容,主要是來學(xué)習(xí)UIView Animation一連串的實(shí)現(xiàn)效果,具體內(nèi)容我們來看本文如何實(shí)現(xiàn)。

iPhone開發(fā)中關(guān)于UIView Animation實(shí)現(xiàn)效果是本文要介紹的內(nèi)容,主要是來學(xué)習(xí)UIView Animation一連串的實(shí)現(xiàn)效果,具體內(nèi)容我們來看本文如何實(shí)現(xiàn)。之前受某人影響以為一連串的UIView Animation 只能這么寫:

在某個(gè)animation 設(shè)置delegate ,然后在 delegate 函數(shù)中再調(diào)用另一個(gè)函數(shù)。

今天偷閑決定看 iPhone cookbook 代碼查漏補(bǔ)缺下,結(jié)果發(fā)現(xiàn)這代碼:

C代碼

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

tnnd 原來可以這么寫。

同時(shí)學(xué)到個(gè)新玩意。

C代碼

  1. [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];  

PS. 原來這個(gè)例子就叫做 Modal View Animation 罪過罪過,搞了這么久iPhone還不知道這東西。

抱歉,看錯了,原來是作者自己實(shí)現(xiàn)的方法,仔細(xì)一看原來

C代碼

  1. commitModalAnimations  

具體代碼實(shí)現(xiàn)是這樣的。

Java代碼

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

小結(jié):iPhone開發(fā)中關(guān)于UIView Animation實(shí)現(xiàn)效果的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!

責(zé)任編輯:zhaolei 來源: 網(wǎng)易博客
相關(guān)推薦

2013-07-25 13:43:23

iOS開發(fā)學(xué)習(xí)UIView的Anim

2011-08-16 18:13:42

IPhone開發(fā)UIView動畫

2011-08-15 13:50:06

IPhone開發(fā)UIView動畫

2011-08-12 14:04:53

iPhone動畫

2011-08-12 11:31:46

iPhoneUIView動畫

2011-08-11 10:16:23

iPhoneUIView視圖

2011-08-11 10:27:37

iPhoneUIView視圖

2011-07-08 15:08:16

iPhone 圖片

2011-08-10 14:40:23

iPhone動畫

2011-07-08 10:15:15

IPhone 動畫

2011-08-09 17:12:30

iPhoneCFRunLoop

2011-07-29 13:27:48

iPhone 開發(fā) Nib

2011-08-15 13:44:07

iPhone開發(fā)UITableView

2011-08-22 15:15:49

iPhone開發(fā)NSMutableAr排序

2011-08-18 15:24:40

iPhone國際化

2011-08-08 14:07:49

iPhone開發(fā) 字體

2011-08-15 09:58:25

iPhoneXib文件UITableView

2011-08-16 18:56:11

iPhone開發(fā)Three20

2011-08-19 10:05:30

iPhone開發(fā)

2011-07-26 14:18:20

點(diǎn)贊
收藏

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