玩&用 UIButton 制作动画?
我正在做一些 RnD 工作,期待专家的建议:
我必须使用任何定义的背景图像创建一个自定义按钮。这样用户就可以平滑地向任意方向扔按钮,在这种情况下,总覆盖距离与 UIButton 上扔按钮所施加的压力成正比。
任何人都可以指导我以便我完成这项任务吗?
I am doing some RnD work, looking forward for experts suggestion:
I have to create a custom Button with any defined background image. So that user can throw that button in any direction with smooth way, under which total covered distance is directly proportional to pressure applied on UIButton to throw it.
Can any one guide me so that i can cover this task ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个好的开始是将
UIPanGestureRecognizer
附加到您的按钮(或视图或其他),然后使用velocityInView:
。来自 UIPanGestureRecognizer.h:使用速度(可能与
translationInView:
结合使用),您可以根据手势的速度和速度移动按钮。A good start would be to attach a
UIPanGestureRecognizer
to your button (or view or whatever), then usevelocityInView:
. From UIPanGestureRecognizer.h:Using the velocity (possibly in conjunction with
translationInView:
) you can then move your button according to the speed and velocity of the gesture.