无限循环动画
我正在尝试创建无限循环的动画,但遇到了一些麻烦。我正在使用这行代码使我的视图“颤动”红色,但是当我调用这一行时它可以工作,但使我的用户界面无响应。
[UIView animateWithDuration:1.0f
delay:0.0f
options:(UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat)
animations:^{
self.backgroundColor = [UIColor colorWithRed:0.5 green:0.0 blue:0.0 alpha:1.0];
}
completion:nil];
我的问题是:1)这是正确的方法吗? 2)为什么这会导致用户界面无响应?
I am trying to create an infinitely looping animation but am having some trouble. I am using this line of code the make my view "throb" red but when I call this line it works but make my UI unresponsive.
[UIView animateWithDuration:1.0f
delay:0.0f
options:(UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat)
animations:^{
self.backgroundColor = [UIColor colorWithRed:0.5 green:0.0 blue:0.0 alpha:1.0];
}
completion:nil];
My questions are: 1)is this the correct way to do this? 2)why does this make the UI unresponsive?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的选项需要包含
UIViewAnimationOptionAllowUserInteraction
。默认情况下,UIView 动画在运行时禁用输入。Your options need to include
UIViewAnimationOptionAllowUserInteraction
. By default, UIView animations disable input while they're running.