2016-1-10 Group Animation Learning Animation Example

Source: Internet
Author: User

////VIEWCONTROLLER.M//Chesiaodi Demo////Created by Mac on 16/1/11.//copyright©2016 year Mac. All rights reserved.//#import "ViewController.h"@interfaceViewcontroller () @property (weak, nonatomic) Iboutlet Uiimageview*Circleview;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib. //Add three sector buttons     for(inti =0; i<3; i + +) {NSString*imgname = [NSString stringWithFormat:@"circle%d", i +1]; UIButton*BTN =[UIButton Buttonwithtype:uibuttontypecustom]; UIImage*img =[UIImage Imagenamed:imgname];        [Btn setbackgroundimage:img Forstate:uicontrolstatenormal]; //because the frame of the given button picture is corresponding to the size of the background picture, it is important to note hereBtn.frame =Self.circleView.bounds;    [Self.circleview ADDSUBVIEW:BTN]; }            //Add a center button to the backgroundUIButton *centerbtn =[UIButton Buttonwithtype:uibuttontypecustom]; [Centerbtn setbackgroundimage:[uiimage imagenamed:@"Home_btn_dealer_had_bind"] Forstate:uicontrolstatenormal]; //Add in[Self.view addsubview:centerbtn]; Centerbtn.bounds= CGRectMake (0,0, the, the); Centerbtn.center=Self.circleView.center;    [Centerbtn addtarget:self Action: @selector (Centerbtnclick:) forControlEvents: (UIControlEventTouchUpInside)]; }- (void) Centerbtnclick: (UIButton *) centerbtn{cgfloat currentalpha=Self.circleView.alpha; if(Currentalpha = =1) {Self.circleView.alpha=0; }Else{Self.circleView.alpha=1; }    //Create a group animationCaanimationgroup *groupani =[Caanimationgroup animation]; //Create a core animation//Hide AnimationCabasicanimation *opacityani =[cabasicanimation animation]; Opacityani.keypath=@"Opacity"; //Zoom AnimationCakeyframeanimation *scaleani =[cakeyframeanimation animation]; Scaleani.keypath=@"Transform.scale"; //Rotate AnimationCabasicanimation *rotationani =[cabasicanimation animation]; Rotationani.keypath=@"transform.rotation"; if(Currentalpha = =1) {//need to hideOpacityani.fromvalue = @1; Opacityani.tovalue= @0; Scaleani.values= @[@1,@1.2,@0]; Rotationani.fromvalue[Email protected] [@0]; Rotationani.tovalue=@[@ (m_pi_4)]; }Else{//need to displayOpacityani.fromvalue = @0; Opacityani.tovalue= @1; Scaleani.values= @[@0,@1.2,@1]; Rotationani.fromvalue=@[@ (m_pi_4)]; Rotationani.tovalue= @[@0]; } groupani.animations=@[opacityani,scaleani,rotationani]; Groupani.duration=2;    [Self.circleView.layer Addanimation:groupani Forkey:nil]; }@end

2016-1-10 Group Animation Learning Animation Example

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.