iOS animation development of the second--uiview animation execution another way

Source: Internet
Author: User

iOS animation development of the second--uiview animation execution another way

The previous blog introduced some of UIView's common animations, through block blocks, we can easily create a simple animation effect: http://my.oschina.net/u/2340880/blog/ 484457, this blog introduces a more traditional method of performing uiview animations.

It's a bit of a hassle compared to the way blocks are, and Apple's official recommendation is that we use block to create animations, and we can focus more on the implementation of animation logic. The use of the Begin and commit methods is divided into three main steps:

First, set the animation to start

[UIView beginanimations:@ "test" context:nil];

The two parameters in this function, the first one to set the identity ID of an animation, usually the second argument is nil.

ii. parameter settings for animation execution

+ (void) Setanimationdelegate: (ID) delegate;

Set the agent for this animation to perform an animation start or end action

+ (void) Setanimationwillstartselector: (SEL) selector;

Sets the callback to be executed when the animation starts

+ (void) Setanimationdidstopselector: (SEL) selector;

sets the callback to be executed after the animation finishes

+ (void) Setanimationduration: (nstimeinterval) duration;

set time for animation execution

+ (void) Setanimationdelay: (nstimeinterval) delay;

Setting delay for deferred execution

+ (void) Setanimationstartdate: (nsdate *) StartDate;

Set a revelation time for animations

+ (void) Setanimationcurve: (uiviewanimationcurve) curve;

to set the linear effect of animation playback, the Uiviewanimationcurve enumeration is as follows:

typedef ns_enum (Nsinteger, Uiviewanimationcurve) {uiviewanimationcurveeaseinout,//Fade Uiviewanimationcur Veeasein,//fade-in uiviewanimationcurveeaseout,//fade-out uiviewanimationcurvelinear//linear}

+ (void) Setanimationrepeatcount: (float) repeatcount;

Set Animation loop play times

+ (void) setanimationrepeatautoreverses: (BOOL) repeatautoreverses;

Set up animation reverse execution

Third, submit the animation

+ (void) commitanimations;

For example:

UIView * view = [[UIView alloc]initwithframe:cgrectmake (100, 100, 100, 100)];    [Self.view Addsubview:view];    View.backgroundcolor=[uicolor Redcolor];    [UIView beginanimations:@ "test" context:nil];    [UIView Setanimationduration:3];    View.backgroundcolor=[uicolor Orangecolor]; [UIView commitanimations];//executes the commit, the animation begins execution


a little bit of advice: this way of creating UIView animation is the same as the Block method in the previous blog, but the efficiency is not high, writing code will be cumbersome and lengthy, in the development, if there is no special compatibility requirements, the way of using block will be more efficient and convenient.

iOS animation development of the second--uiview animation execution another way

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.