IPhone DevelopmentAboutUIView AnimationThe implementation effect is the content to be introduced in this article, mainly to learnUIView AnimationFor a series of implementation results, let's take a look at how this article is implemented. It was previously influenced by a seriesUIView AnimationThis is the only way to write:
Set delegate in an animation, and then call another function in the delegate function.
Today, I decided to check for missing iPhone cookbook code and found the code:
C code
- // 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 can be written in this way.
Learn new things at the same time.
C code
- [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];
PS. In the past, this example was called Modal View Animation. The iPhone had no idea about this for so long.
Sorry, I got it wrong. It turned out to be the method implemented by the author.
C code
- commitModalAnimations
The specific code implementation is like this.
Java code
- @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
Summary:IPhone DevelopmentAboutUIView AnimationThe content of the implementation effect is introduced. I hope this article will help you!