IOS drag, flick, or fling a UIView

前端 未结 3 670
暗喜
暗喜 2020-12-23 02:17

Was wondering how I would go about flicking or flinging a UIView, such as http://www.cardflick.co/ or https://squareup.com/cardcase demo videos.

I know how to drag i

3条回答
  •  我在风中等你
    2020-12-23 03:08

    iOS doesn't have any built-in API for gravity/inertia. Your best options are:

    1. Simulate the effect with animations: if you are flicking an object toward a target (it doesn't need to bounce off things), you could probably get a pretty good result just by sending it to the target and tweaking the animation timing curve.

    2. Use a physics library. Chipmunk is a high quality one and there is a lot of iOS support available. You set up objects, assign them weights, describe their shapes, and then the library code will give you updated (x,y) coordinates so you can update your objects on screen.

提交回复
热议问题