Ios animateWithDuration和UIViewAnimationOptions AllowUserInteraction
我正在制作一个简单的应用程序,其中包括一个在屏幕上移动的按钮,我希望用户能够在按钮移动时单击它。我有这个:Ios animateWithDuration和UIViewAnimationOptions AllowUserInteraction,ios,button,swift,clickable,user-interaction,Ios,Button,Swift,Clickable,User Interaction,我正在制作一个简单的应用程序,其中包括一个在屏幕上移动的按钮,我希望用户能够在按钮移动时单击它。我有这个: func bonus () { UIView.animateWithDuration(14, delay: 0.1, options: UIViewAnimationOptionsAllowUserInteraction, animations: { self.bonusbutton.cen
func bonus ()
{
UIView.animateWithDuration(14,
delay: 0.1,
options: UIViewAnimationOptionsAllowUserInteraction,
animations: {
self.bonusbutton.center = CGPointMake(self.bonusbutton.center.x + 1000, self.bonusbutton.center.y)
}, completion : nil)
}
这给了我一个“使用未解析标识符UIViewAnimationOptionAllowUserInteraction”
错误
我尝试了选项:UIViewAnimationOptions.AllowUserInteraction
,它可以编译,但不允许在动画期间单击按钮
我去过,但我对斯威夫特还是相当陌生的。我做错了什么?谢谢 您可以对该选项使用.AllowUserInteraction,但这不会解决您的问题。当您制作动画(使用animateWithDuration)时,视图的帧将立即设置为最终位置,因此触摸点实际上将在那里,而不是您看到移动视图的位置。如果希望用户能够与按钮交互,则必须通过使用计时器递增地移动按钮来设置其动画