iPhone開發(fā)中關(guān)于UIView Animation實現(xiàn)效果
iPhone開發(fā)中關(guān)于UIView Animation實現(xiàn)效果是本文要介紹的內(nèi)容,主要是來學(xué)習(xí)UIView Animation一連串的實現(xiàn)效果,具體內(nèi)容我們來看本文如何實現(xiàn)。之前受某人影響以為一連串的UIView Animation 只能這么寫:
在某個animation 設(shè)置delegate ,然后在 delegate 函數(shù)中再調(diào)用另一個函數(shù)。
今天偷閑決定看 iPhone cookbook 代碼查漏補(bǔ)缺下,結(jié)果發(fā)現(xiàn)這代碼:
C代碼
- // Hide the bar button and show the view
 - self.navigationItem.rightBarButtonItem = nil;
 - [self.view viewWithTag:101].alpha = 1.0f;
 - // Bounce to 115% of the normal size
 - [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
 - [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
 - [UIView setAnimationDuration:0.4f];
 - [self.view viewWithTag:101].transform = CGAffineTransformMakeScale(1.15f, 1.15f);
 - [UIView commitModalAnimations];
 - // Return back to 100%
 - [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
 - [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
 - [UIView setAnimationDuration:0.3f];
 - [self.view viewWithTag:101].transform = CGAffineTransformMakeScale(1.0f, 1.0f);
 - [UIView commitModalAnimations];
 - // Pause for a second and appreciate the presentation
 - [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];
 - // Slowly zoom back down and hide the view
 - [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
 - [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
 - [UIView setAnimationDuration:1.0f];
 - [self.view viewWithTag:101].transform = CGAffineTransformMakeScale(0.01f, 0.01f);
 - [UIView commitModalAnimations];
 - // Restore the bar button
 - [self.view viewWithTag:101].alpha = 0.0f;
 
tnnd 原來可以這么寫。
同時學(xué)到個新玩意。
C代碼
- [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];
 
PS. 原來這個例子就叫做 Modal View Animation 罪過罪過,搞了這么久iPhone還不知道這東西。
抱歉,看錯了,原來是作者自己實現(xiàn)的方法,仔細(xì)一看原來
C代碼
- commitModalAnimations
 
具體代碼實現(xiàn)是這樣的。
Java代碼
- @interface UIViewDelegate : NSObject
 - {
 - CFRunLoopRef currentLoop;
 - }
 - @end
 - @implementation UIViewDelegate
 - -(id) initWithRunLoop: (CFRunLoopRef)runLoop
 - {
 - if (self = [super init]) currentLoop = runLoop;
 - return self;
 - }
 - -(void) animationFinished: (id) sender
 - {
 - CFRunLoopStop(currentLoop);
 - }
 - @end
 - @implementation UIView (ModalAnimationHelper)
 - + (void) commitModalAnimations
 - {
 - CFRunLoopRef currentLoop = CFRunLoopGetCurrent();
 - UIViewDelegate *uivdelegate = [[UIViewDelegate alloc] initWithRunLoop:currentLoop];
 - [UIView setAnimationDelegate:uivdelegate];
 - [UIView setAnimationDidStopSelector:@selector(animationFinished:)];
 - [UIView commitAnimations];
 - CFRunLoopRun();
 - [uivdelegate release];
 - }
 - @end
 
小結(jié):iPhone開發(fā)中關(guān)于UIView Animation實現(xiàn)效果的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!















 
 
 
 
 
 
 