Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Infinitely looping animation

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?

like image 420
Vic320 Avatar asked May 04 '11 18:05

Vic320


People also ask

What is an infinite loop called?

An infinite loop (sometimes called an endless loop ) is a piece of coding that lacks a functional exit so that it repeats indefinitely. In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.


1 Answers

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

like image 129
Noah Witherspoon Avatar answered Sep 30 '22 08:09

Noah Witherspoon