开发者

Play & animate with UIButton?

I am doing some RnD work, looking forward for experts suggestion:

I have to create a custo开发者_如何转开发m 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 ?


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;

Using the velocity (possibly in conjunction with translationInView:) you can then move your button according to the speed and velocity of the gesture.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜