////VIEWCONTROLLER.M//icon Jitter////Created by Mac on 16/1/11.//copyright©2016 year Mac. All rights reserved.//#import "ViewController.h"@interfaceViewcontroller () @property (weak, nonatomic) Iboutlet Uiimageview*ImageView;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib. }-(ibaction) startanimation {cakeyframeanimation*rotationani =[cakeyframeanimation animation]; Rotationani.keypath=@"transform.rotation"; //calculate the radian of the rotationCGFloat angle = M_pi_4 *0.1; //set the path of the rotationRotationani.values = @[@ (-angle), @ (angle), @ (-angle)]; Rotationani.duration=0.2; Rotationani.repeatcount=maxfloat; [Self.imageView.layer Addanimation:rotationani Forkey:@"Shake"]; }-(ibaction) endanimation {//removing animations with key[Self.imageView.layer Removeanimationforkey:@"Shake"];}- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}@end
2016-1-10 Core Animation icon Jitter