Core Animation -07-Group Animation-day4

Source: Internet
Author: User

1 //2 //VIEWCONTROLLER.M3 //Caanimationgroup4 //5 //Created by Zhujiacong on 16/4/19.6 //copyright©2016 year WXHL. All rights reserved.7 //8 9 #import "ViewController.h"Ten  One @interfaceViewcontroller () A  -  -@property (Weak, nonatomic) Iboutlet UIView *Animationview; the  - @end -  - @implementationViewcontroller +  -  +  A- (void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (Uievent *)Event { at      -     //Rotate Animation -Cabasicanimation *animation1 = [cabasicanimation animationwithkeypath:@"transform.rotation.z"]; -Animation1.fromvalue = @0; -Animation1.tovalue =@ (m_pi_2); -      in     //Set Animation time -Animation1.duration =1; to     //Repeat rotation animation +Animation1.repeatcount =huge_valf; -      the      * //[_animationview.layer addanimation:animation1 forkey:nil]; $     Panax Notoginseng     //When you use Keyframe animations to change the background color -     //1 cannot use Uicolor, must use Cgcolor the     //2 cannot wrap Cgcolor as nsvalue need to use bridging to convert to ID type +Nsarray *colors = @[(__bridgeID) [Uicolor Redcolor]. Cgcolor, A(__bridgeID) [Uicolor Orangecolor]. Cgcolor, the(__bridgeID) [Uicolor Yellowcolor]. Cgcolor, +(__bridgeID) [Uicolor Greencolor]. Cgcolor, -(__bridgeID) [Uicolor Cyancolor]. Cgcolor, $(__bridgeID) [Uicolor Bluecolor]. Cgcolor, $(__bridgeID) [Uicolor Purplecolor]. Cgcolor -                         ]; -      theCakeyframeanimation *animation2 = [cakeyframeanimation animationwithkeypath:@"BackgroundColor"]; -Animation2.values =colors;Wuyi      the     //Set Animation time -Animation2.duration =Ten; Wu     //Repeat rotation animation -Animation2.repeatcount =huge_valf; About  $ //[_animationview.layer addanimation:animation2 forkey:nil]; -      -      -     //Create an animation group ACaanimationgroup *group =[Caanimationgroup animation]; +     //add animations to the animation group theGroup.animations =@[animation1, Animation2]; -      $     //set the duration of a group animation theGroup.duration =Ten; the      the [_animationview.layer addanimation:group forkey:nil]; the      - } in  the  the  About- (void) Viewdidload { the [Super Viewdidload]; the      the_animationview.layer.anchorpoint = Cgpointmake (0.5,2.W); +      -      the }Bayi  the @end

Core Animation -07-Group Animation-day4

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.