self.locationTimer =[NSTimer scheduledTimerWithTimeInterval: 0.01 target: self selector:@selector(transformAction) userInfo: nil repeats: YES];-(void)
self.locationTimer =[NSTimer scheduledTimerWithTimeInterval: 0.01 target: self selector:@selector(transformAction) userInfo: nil repeats: YES];
-(void)transformAction {
angle = angle – 0.1;//angle角度 double angle;
if (angle < -6.28) {//大於 M_PI*2(360度) 角度再次從0開始
angle = 0;
}
CGAffineTransform transform=CGAffineTransformMakeRotation(angle);
self.animationImageView.transform = transform;
}
然後再在特定的地方使用
//關閉定時器
[self.locationTimer setFireDate:[NSDate distantFuture]];
//開啟定時器
[self.locationTimer setFireDate:[NSDate distantPast]];
版權聲明:歡迎轉載,請註明出處:蝸牛愛課 • 移動互聯網