gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 19:56:36 25 4
gpt4 key购买 nike

我正在尝试以一定间隔重复旋转图像(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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com