Reprinted from: http://blog.csdn.net/xunyn/article/details/8128031
Animation is one of the most important features of the iOS interface, where Caanimation is the abstract parent of all animated objects and, as a newcomer, uses more of the animation method (class method) under UIView. There are several ways to use the animation under UIView.
Method One: Set Beginanimations
Where Memberview is a view of the child view that needs to be added, Mivc.view is a sub-view, when used, you need to replace these two places
[CPP]View Plaincopyprint?
- [UIView beginanimations:@"View Flip" context:nil];
- [UIView Setanimationduration:1];
- [UIView setanimationtransition:uiviewanimationtransitionflipfromright Forview:memberview Cache:YES];
- [Memberview AddSubview:mivc.view];
- [UIView commitanimations];
It should be noted that [UIView commitanimations] must be used and the animation will take effect
by [UIView Setanimationduration:1]; Set the duration.
After IOS4.0, we have a new method, + (void) Transitionwithview: (UIView *) View Duration: (nstimeinterval) Duration options: ( uiviewanimationoptions) options animations: (void (^) (void)) animations completion: (void (^) (BOOL finished)) completion is still a UIView class method, but using the Block object, the Block object is a set of instructions that can be passed (like a variable) and can be imagined as a C-language function pointer.
Method Two:
Where in the current view, delete [Blueviewcontroller view], add [Yellowviewcontroller view], when used, these two places to replace
[CPP]View Plaincopyprint?
- [UIVIEW TRANSITIONWITHVIEW:SELF.VIEW  
- duration:0.2
- options: uiviewanimationoptiontransitionflipfromleft
- animations:^{ [[ Blueviewcontroller view] removefromsuperview]; [[self view] insertsubview: yellowviewcontroller.view atindex:0]; }
- completion:NULL];
Where animations: After the block is a change to a particular view, it cannot be null,completion: after the block for the animation after the execution of the code block, you can be null.
According to the manual, during the entire animation process, user interaction is temporarily invalid for this view (and before IOS5.0, the user interaction is not valid for the entire application during the animation process), and if you want the user to interact with the view, you can change UIViewAnimationOptionAllowUserInteraction
the value.
Use animation to control animations under UIView