Reputation: 277
I want to rotate an image by 360 degree delay for 2 or 3 seconds again rotate it by 360 degree and the process should continue on. Any possible suggestions for the same ? Actually tried Cgaffinetransfom but its not working for 360 degree .
Upvotes: 2
Views: 613
Reputation: 1801
You could try this method:
- (void)rotateImageView{
[UIView animateWithDuration:0.4f delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
[yourImageView setTransform:CGAffineTransformRotate(yourImageView.transform, M_PI_2)];
}completion:^(BOOL finished){
if (finished) {
[self rotateImageView];
}
}];
}
Upvotes: 1
Reputation: 1781
You can rotate your image like this:
[YourImageView setTransform:CGAffineTransformMakeRotation(10*(M_PI/360))];
Now to perform it continuous you need to set the timer like this:
[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(doRotateImage) userInfo:nil repeats:YES];
Rotate function:
-(void)doRotateImage{
[YourImageView setTransform:CGAffineTransformMakeRotation(10*(M_PI/360))];
}
Thats it.
Upvotes: 1