动画时UIButton没有响应

ios*_*eak 3 objective-c

出于某种原因,我的UIButton在动画制作时不会响应UIControlEvents.这是我的动画:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:[duration intValue]];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
// change parent UIView's frame
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

当它到达终点时,它会让我点击它...但不是它的动画.顺便说一句,我正在使用UIControlEventTouchUpInside.

谢谢.

wat*_*n12 7

您应该设置UIViewAnimationOptionAllowUserInteraction动画选项

使用块动画更容易完成:

[UIView animateWithDuration:[duration intValue] options:UIViewAnimationOptionAllowUserInteraction animations^{
    //set parent UIView's frame
}];
Run Code Online (Sandbox Code Playgroud)