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