【问题标题】:Button not preforming action from being tapped while animating in Xcode using UIView Animation使用 UIView 动画在 Xcode 中制作动画时,按钮不会执行被点击的动作
【发布时间】:2014-12-12 00:18:11
【问题描述】:

我正在制作一个游戏,我正在尝试使用 UIView Animation 移动一个名为 tapMe 的按钮,但我需要它在制作动画时是可录制的。

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

xRandom 和 yRandom 是随机生成的整数,而 _tapMe 连接到按钮,我可以肯定,因为它确实会移动。

【问题讨论】:

    标签: ios objective-c xcode animation uiview


    【解决方案1】:

    当您使用 animateWithDuration 时,按钮的框架会立即移动到其最终位置(在那里可以触摸),但表示层是动画的,因此在动画期间您看到按钮的位置不是可触摸区域的位置.您要么需要点击测试表示层,要么通过使用计时器以小增量移动按钮来为按钮设置动画。请参阅此处的答案以获取更多详细信息,UIButton can't be touched while animated with UIView animateWithDuration

    【讨论】:

      猜你喜欢
      • 2020-10-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-30
      • 2011-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多