UIView 正在进行动画时,默认禁止用户交互

今天遇到一个问题,使用

[UIView animateWithDuration:3 animations:^{
    self.contentView.backgroundColor = [UIColor clearColor];
}];

方法进行动态改变控件背景色,但发现在动画进行时,控件死活不响应用户手势,经过查看API,发现有个参数:

UIViewAnimationOptionAllowUserInteraction      = 1 <<  1, // turn on user interaction while animating

猜想该动画默认是不允许用户进行交互的

通过在该动画中添加该参数:UIViewAnimationOptionAllowUserInteraction

[UIView animateWithDuration:3 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
    self.contentView.backgroundColor = [UIColor clearColor];
} completion:nil];

使问题得以解决。

添加新评论

电子邮件地址不会被公开,评论内容可能需要管理员审核后显示。