如何通过点击并按住来旋转 UIButton(按住 - 用手指旋转)
我是ios开发菜鸟。我需要一些帮助。我有带有“箭头”图片的自定义 UIButton,因此我需要通过按下并在 +360 gr 中移动手指来旋转此按钮。 -360 克,如指南针箭头。
I'm noob in ios development. I need some help. I have custom UIButton with picture "arrow", so I need to rotate this button by pressing and moving finger in +360 gr. and -360 gr., like compass arrow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是进行旋转的代码。
Here is code that makes rotation.
具体来说,可以自定义一个rotateView,然后:
1:在“
touchesBegan
”的委托方法中,获取手指的initialPoint
和initialAngle
。2:在“
touchesMoved
”中,获取手指的newPoint
:3:最后,在“
touchesEnded
”中可以计算出最终的角速度。
如果有任何困惑,为了了解更多详细信息,您可以写信回来。
In detail, you can custom a rotateView,then:
1: In the delegate method of "
touchesBegan
", getinitialPoint
of finger andinitialAngle
.2: During "
touchesMoved
",get thenewPoint
of finger:3: At last, in "
touchesEnded
" you can calculate finalAngularVelocity
.If anything being confused, for more detail, you can write back.