问题描述
我做了一些工作,RND,期待着专家建议:
I am doing some RnD work, looking forward for experts suggestion:
我要创建一个自定义按钮与任何定义的背景图片。这样用户可以扔在光滑的方式任意方向该按钮,在其所占比重合计覆盖距离成正比,施加的UIButton pressure扔掉它。
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 ?
推荐答案
一个良好的开端将是附上 UIPanGestureRecognizer
来的按钮(或视图或其他),然后使用 velocityInView:
。从UIPanGestureRecognizer.h:
A good start would be to attach a UIPanGestureRecognizer
to your button (or view or whatever), then use velocityInView:
. From UIPanGestureRecognizer.h:
// velocity of the pan in pixels/second in the coordinate system of the specified view
- (CGPoint)velocityInView:(UIView *)view;
使用速度(可能会同 translationInView:
),那么你可以根据手势的速度和移动速度的按钮
Using the velocity (possibly in conjunction with translationInView:
) you can then move your button according to the speed and velocity of the gesture.
这篇关于播放和放大器;与动画的UIButton?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!