I am trying to get the iPhone background Color to change color every X number of seconds.
How can I do this?
I've been trying a UIAnimation but can only get it to change to the very last color in a list.
Thanks alot!
I am trying to get the iPhone background Color to change color every X number of seconds.
How can I do this?
I've been trying a UIAnimation but can only get it to change to the very last color in a list.
Thanks alot!
You could use a custom animation to step through an array of colors, or just use a timer. The timer would call a function that sets the chosen background color and then calls setNeedsDisplay on the view. E.e.
-(void) timerEntry
{
UIColor* color = [colorArray objectAtIndex: colorIndex++];
self.backgroundColor = color;
[self setNeedsDisplay];
if (colorIndex == [colorArray count])
colorIndex = 0;
}
Then to setup the timer:
[NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(timerEntry) userInfo: nil repeats: NO];