1

I have a game that I am making and I am trying to move a button named tapMe using UIView Animation but I need it to be tapeable while it is being animated.

[UIView animateWithDuration:0.5 animations:^{
    _tapMe.center = CGPointMake(xRandom, yRandom);
}];

Where xRandom and yRandom are randomly generated integers and _tapMe is connected to the button, I am certain because it does move.

1 Answers1

1

When you use animateWithDuration, the button's frame is moved to its final position immediately (it will be touchable there), but the presentation layer is animated, so where you see the button during the animation is not where the touchable area will be. You either need to hit test the presentation layer, or animate the button by moving it in small increments with a timer. See the answer here for more detail, UIButton can't be touched while animated with UIView animateWithDuration

Community
  • 1
  • 1
rdelmar
  • 103,982
  • 12
  • 207
  • 218