ios - IOS/Objective-C:360图像旋转问题

标签 ios objective-c animation

我正在尝试以一定间隔重复旋转图像(360)。我发现这个答案(Image rotation in iOS)似乎还可以,但是对我来说不起作用。当我加载VC时,我可以看到轻微的移动,仅此而已。有任何想法吗?我正在使用的代码:

 - (void)viewDidAppear:(BOOL)animated {
    [self.compass setTransform:CGAffineTransformMakeRotation(10*(M_PI/360))];


    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(rotation) userInfo:nil repeats:YES];

}
-(void)rotation{
    [self.compass setTransform:CGAffineTransformMakeRotation(10*(M_PI/360))];

}

编辑:
- (void)viewDidAppear:(BOOL)animated {
    [self.compass setTransform:CGAffineTransformMakeRotation(10*(M_PI/360))];


    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(rotation) userInfo:nil repeats:YES];

}
-(void)rotation{
    [self.compass setTransform:CGAffineTransformMakeRotation(10*(M_PI/360))];
    CGAffineTransform transform = CGAffineTransformRotate(self.compass.transform, 10*(M_PI/360));
    [self.compass setTransform:transform];
}

最佳答案

使旋转动画如下:

[UIView animateWithDuration:0.3 animations:^{
        compas.transform = CGAffineTransformMakeRotation(M_PI/2);
    }];

关于ios - IOS/Objective-C:360图像旋转问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42260761/

相关文章:

ios - Core Image CIColorControls 亮度滤镜会产生错误的效果。如何更改图像的亮度?

objective-c - NSDateFormatter 从字符串中返回不正确的日期

iphone - 即使 userInteractionEnabled 设置为 NO,UITextField 也会显示光标

android - ChangeBounds 安卓过渡

jquery - 通过触摸功能简单地从左向右拖动

android - 使光标在自定义 View 中闪烁

objective-c - FB 请求输出在 iOS 中不起作用

iphone - 如何从pdf文件中的FileAttachment Annotation获取EmbeddedFiles

iphone - iOS AVPlayer seektotime 锁定在某些点

iphone - PDF 417 检测和解码