Animation effect is one of the important features of the IOS interface. CAAnimation is the abstract parent class of all animation objects. For new users, animation methods (class methods) under UIView are mostly used ). You can use the following methods to use an animation under UIView.
Method 1: Set beginAnimations
Here, memberView is the view of the subview to be added, and mivc. view is the subview. You need to replace these two places when using it.
[Cpp]
[UIView beginAnimations: @ "view flip" context: nil];
[UIView setAnimationDuration: 1];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView: memberView cache: YES];
[MemberView addSubview: mivc. view];
[UIView commitAnimations];
Note that [UIView commitAnimations] must be used for the animation to take effect.
Use [UIView setAnimationDuration: 1]; To 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 the class method of UIView, but the Block object is used, and the Block object is a set of commands, it can be passed (like a variable) and imagined as a function pointer in C language.
Method 2:
In the current view, delete [blueViewController view] and add [yellowViewController view]. during use, replace
[Cpp]
[UIView transitionWithView: self. view
Duration: 0.2
Options: UIViewAnimationOptionTransitionFlipFromLeft
Animations: ^ {[[blueViewController view] removeFromSuperview]; [[self view] insertSubview: yellowViewController. view atIndex: 0];}
Completion: NULL];
Animations: The block after the animation is changed to a specific view. The block cannot be NULL, And the completion is the code block to be executed after the animation is executed. The block can be NULL.
According to the manual, user interaction is temporarily ineffective for this view during the entire animation process (whereas before IOS5.0, user interaction is ineffective for the entire application during the animation process ), if you want to interact with a view, you can change the value of UIViewAnimationOptionAllowUserInteraction.