设置动画时UIButton没有响应



由于某些原因,我的UIButton在制作动画时不会响应UIControlEvents。以下是我的动画:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:[duration intValue]];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
// change parent UIView's frame
[UIView commitAnimations];

当它到达结尾时,它会让我点击它……但不是在它制作动画的时候。顺便说一下,我正在使用UIControlEventTouchUpInside。

谢谢。

您应该设置UIViewAnimationOptionAllowUserInteraction动画选项

块动画更容易实现:

[UIView animateWithDuration:[duration intValue] options:UIViewAnimationOptionAllowUserInteraction animations^{
    //set parent UIView's frame
}];

最新更新