Objective C UIImageView 旋转动画效果不佳
我正在表格单元格中创建指南针,因此图像视图的旋转出现问题,它从资源中图像的位置重新开始。
这是我的代码的一部分:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDelegate:self];
if(cellValue.direction == 0){
cell.compass.transform = CGAffineTransformRotate(cell.compass.transform,DegreesToRadians([cellValue.fixedDirection floatValue]));
} else {
cell.compass.transform = CGAffineTransformRotate(cell.compass.transform,DegreesToRadians([cellValue.direction floatValue]));
}
[UIView commitAnimations];
cell.compass 是 UIimageView ,其中有垂直箭头的图像。如果方向为 0,那么它应该达到该度数,在从罗盘获得角度后,它会进入 else 子句。因此图像从该垂直位置开始旋转,而不是从最后旋转的位置开始旋转。
如何获得最后的旋转位置并从那里继续
谢谢!
I am creating compass in a table cell so I have problem with the rotation of the image view it start all over again from the position which is the image in the resources.
this is part of my code:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDelegate:self];
if(cellValue.direction == 0){
cell.compass.transform = CGAffineTransformRotate(cell.compass.transform,DegreesToRadians([cellValue.fixedDirection floatValue]));
} else {
cell.compass.transform = CGAffineTransformRotate(cell.compass.transform,DegreesToRadians([cellValue.direction floatValue]));
}
[UIView commitAnimations];
cell.compass is UIimageView and I have image in it that is arrow vertical. if the direction is 0 then it should get to that degree and after it get angle from compass it goes to the else clause. So the image starst to rotate from that vertical position not from the last rotated position.
how to get the last rotated position and continue from there
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用
removedOnCompletion = NO
旋转视图的图层,而不是旋转 UIViewTry to rotate view's layer with
removedOnCompletion = NO
instead of rotate UIView我找到了这样的问题解决方案:
固定方向是从北到该地方的方向!方向是指南针或 trueHeading 的当前方向,
我希望我有所帮助:)
I found a solution to the problem like this:
fixed dir is the direction in degree from north to the place! and orientation is the current orientation in degree from the compass or trueHeading
I hope I helped :)