////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