UIView animation effects

Source: Internet
Author: User

Making UI interfaces, implementing program functions is a priority, but using animations to enhance the experience, people should not reject it.

So what's the problem?

One: Steady:

Step by step, after all, impatient to eat hot tofu.

1. Turn on an animation

2, set various properties of the animation: animation duration, time delay, auto-return, animation repetition, transition animation ...

3, sets the end state of the animated UI when it is, the final position of the UI, and so on.

4, commit the animation.

Done. Specific details are as follows:

  //= = =---start animation---= = =[UIView Beginanimations:nil Context:nil]; //--duration of animation---[UIView setanimationduration:2]; //==--Animation Delay[UIView Setanimationdelay:1]; //= = Set auto return animation = = =[UIView Setanimationrepeatautoreverses:yes]; //= =---Set the number of animation repetitions---= =[UIView Setanimationrepeatcount:2.5]; //==--setting up a proxy for animations 1--==[UIView setanimationdelegate:self];//= = =---Set the action when the animation is complete 2---= = =[UIView setanimationdidstopselector: @selector (ChangeColor)]; //Set Transition animations[UIView setanimationtransition:uiviewanimationtransitionflipfromright forview:_view Cache:yes];//= = =---The effect of the animation to be completed---= =_view.center=Self.view.center; _view.bounds=cgrectmake (0,0, -, -); _view.alpha=0.5; //= = =---commit animation---= = =[UIView commitanimations]; */

2, Shortcut:

If you feel that the above steps are too cumbersome, then you can only use that trick.

The "block" mode of animation, using UIView call class method, according to the actual needs, choose a different method. In particular, multiple animation processes can be executed consecutively (the next animation at the end of an animation).

//======------Block way to achieve UIView animation------======[UIView animatewithduration:2animations:^{//two-second animation _view.center=Self.view.center; }completion:^(BOOL finished) {//At the end of the next animation [UIView animatewithduration:2animations:^{_view.bounds=cgrectmake (0,0, -, -); }completion:^(BOOL finished) {//At the end of the next animation, nested layers, and so on. [UIView animatewithduration:2animations:^{_view.alpha=0.5; }completion:^(BOOL finished) {[UIView animatewithduration:1animations:^{_view.backgroundcolor=[Uicolor Greencolor];            }];        }];    }]; }];}

To the poor Trinidad, to the further heights!

UIView animation effects

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.