1. the simplest, most practical, and most commonly used [mobile animation]
// Move a view
Else ---------------------------------------------------------------------------------------------------------------------------------
+ (Void) moveview :( uiview *) view to :( cgrect) frame during :( float) time {
// Animation starts
[Uiview beginanimations: Nil context: Nil];
// Animation time curve easeinout Effect
[Uiview setanimationcurve: uiviewanimationcurveeaseinout];
// Animation time
[Uiview setanimationduration: Time];
View. Frame = frame;
// The animation ends (or the submission is good)
[Uiview commitanimations];
}
Else ---------------------------------------------------------------------------------------------------------------------------------
Applicability:
It often appears in iPad projects. When a user clicks an image or a piece of information, you will pop up a detailed page [detailview] and initialize the starting frame as cgrectmake (self. view. frame. size. width/2, self. view. size. height/2, 0, 0), end position [frame], commonly used animation interval 0.4f-0.6f.
[Animtiontool moveview: detailview to: frame during: 0.5f];
Result: A view [detailview] is displayed in the middle of the page.
Generally, this view is enlarged to full screen or half screen size, and then automatically disappears after you click it. Therefore, this view is automatically converted into a new view. After receiving the click event, call the [self removefromparentview]; method.
2. Gradually display a view. You need to rewrite this method in the class that calls this method.
Else ---------------------------------------------------------------------------------------------------------------------------------
/*
-(Void) onanimationcomplete :( nsstring *) animationid finished :( nsnumber *) finished context :( void *) Context {
If ([animationid isequaltostring: show_view]) {
// Do something
} Else if ([animationid isequaltostring: hidden_view]) {
// Do something
}
}
*/
+ (Void) showview :( uiview *) view to :( cgrect) frame during :( float) time delegate :( ID) Delegate ;{
[Uiview beginanimations: show_view context: Nil];
[Uiview setanimationduration: Time];
[Uiview setanimationcurve: uiviewanimationcurveeaseinout];
If (delegate! = Nil & [Delegate respondstoselector: @ selector (onanimationcomplete: Finished: context :)]) {
[Uiview setanimationdidstopselector: @ selector (onanimationcomplete: Finished: context :)];
[Uiview setanimationdelegate: Delegate];
}
View. Hidden = no;
View. layer. Opacity = 1.0;
View. Frame = frame;
[Uiview commitanimations];
}
Else ---------------------------------------------------------------------------------------------------------------------------------
3. Gradually hide a view
Else ---------------------------------------------------------------------------------------------------------------------------------
+ (Void) hiddenview :( uiview *) view to :( cgrect) frame during :( float) time delegate :( ID) delegate {
[Uiview beginanimations: hidden_view context: Nil];
[Uiview setanimationduration: Time];
[Uiview setanimationcurve: uiviewanimationcurveeaseinout];
If (delegate! = Nil & [Delegate respondstoselector: @ selector (onanimationcomplete: Finished: context :)]) {
[Uiview setanimationdidstopselector: @ selector (onanimationcomplete: Finished: context :)];
[Uiview setanimationdelegate: Delegate];
}
View. Frame = frame;
View. layer. Opacity = 0.0;
[Uiview commitanimations];
}