开发者

Play & animate with UIButton?

开发者 https://www.devze.com 2023-03-17 08:24 出处:网络
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 direct

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

精彩评论

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

关注公众号