Is it possible to successful animate a moving UIButton?

前端 未结 4 1997
挽巷
挽巷 2020-12-18 13:11

I\'m trying to animate a button which moves around the screen. At any point, the user can push the button. But the button doesn\'t respond to touches. I\'ve tried an animati

4条回答
  •  温柔的废话
    2020-12-18 13:41

    When animating a GUI element like the UIButton, the actual position only changes when the animation is done. This means any touch events during the animation will only work at the starting point of the button. You can get the current displayed position of the button by accessing it's presentationLayer. You'll probably need to implement your own event handling, look at the position when the user touches the screen, and compare that to the bounds you get from the presentationLayer.

提交回复
热议问题