我有一个正在制作的游戏,我正在尝试使用 UIView 动画移动一个名为 tapMe 的按钮,但我需要它在制作动画时可以录制。
[UIView animateWithDuration:0.5 animations:^{
_tapMe.center = CGPointMake(xRandom, yRandom);
}];
其中 xRandom 和 yRandom 是随机生成的整数,而 _tapMe 连接到按钮,我敢肯定,因为它确实会移动。
最佳答案
当您使用 animateWithDuration 时,按钮的框架会立即移动到它的最终位置(在那里它将是可触摸的),但是表示层是动画的,因此您在动画期间看到按钮的位置不是可触摸区域所在的位置.您要么需要点击测试表示层,要么通过使用计时器以小增量移动按钮来为按钮设置动画。有关更多详细信息,请参见此处的答案,UIButton can't be touched while animated with UIView animateWithDuration
关于ios - 使用 UIView Animation 在 Xcode 中制作动画时,按钮不执行被点击的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27434863/