Infinitely looping animation

不羁岁月 提交于 2020-01-01 03:12:36

问题


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?


回答1:


Your options need to include UIViewAnimationOptionAllowUserInteraction. By default, UIView animations disable input while they're running.



来源:https://stackoverflow.com/questions/5888145/infinitely-looping-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!