Image rotation in iOS

2019-07-24 05:35发布

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 .

2条回答
家丑人穷心不美
2楼-- · 2019-07-24 06:04

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];
    }
}];
}
查看更多
爷的心禁止访问
3楼-- · 2019-07-24 06:22

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.

查看更多
登录 后发表回答