IOS simple animation effect

Source: Internet
Author: User
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];

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.