Explanation of Animatekeyframeswithduration method in UIView of iOS7

Source: Internet
Author: User

Explanation of Animatekeyframeswithduration method in UIView of iOS7

In IOS7, a method was added to UIView to use keyframe animations directly without the help of Coreanimation, which is animatekeyframeswithduration

The following is the use of source code:

////VIEWCONTROLLER.M////Created by youxianming on 14/11/26.//Copyright (c) 2014 youxianming. All rights reserved.//#import "ViewController.h"@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; [Self runanimatekeyframes];}- (void) Runanimatekeyframes {/** * relativeduration when the animation starts * Relativestarttime The duration of the animation*/[UIView animatekeyframeswithduration:6. F Delay:0.0Options:uiviewkeyframeanimationoptioncalculationmodelinear Animations:^{[UIView addkeyframewithrelativestarttime:0.0   //the time starting at the beginning of the 6 second (the animation starts in the No. 0 second)Relativeduration:1/3.0 //duration of animation relative to 6 seconds (animation lasts 2 seconds)animations:^{Self.view.backgroundColor=[Uicolor Redcolor];                                                                    }]; [UIView addkeyframewithrelativestarttime:1/3.0 //the time starting at the beginning of the 6 second (the animation starts in the 2nd second)Relativeduration:1/3.0 //duration of animation relative to 6 seconds (animation lasts 2 seconds)animations:^{Self.view.backgroundColor=[Uicolor Yellowcolor];                                  }]; [UIView addkeyframewithrelativestarttime:2/3.0 //the time starting at the beginning of the 6 second (the animation starts in the 4th second)Relativeduration:1/3.0 //duration of animation relative to 6 seconds (animation lasts 2 seconds)animations:^{Self.view.backgroundColor=[Uicolor Greencolor];                                                                }]; } Completion:^(BOOL finished) {[Self runanimatekeyframes]; }];}@end

Details of the place:

Explanation of Animatekeyframeswithduration method in UIView of iOS7

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.