Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force iOS to change background color immediately?

Is there any way to change the background color of a window immediately?

I need a blinking background, i.e. red/green blinking in an interval of a second. As i see, the background color will not change immediately, but only when function is left.

Is there any way to force the system to change it and redraw the window's background immediately?

like image 591
Ole Avatar asked Dec 29 '25 02:12

Ole


1 Answers

- (void)viewDidLoad 
{
    [super viewDidLoad];
    flag = YES;
    NSTimer *mTimer = [NSTimer scheduledTimerWithTimeInterval:.5
                                                       target:self 
                                                     selector:@selector(changeColor)
                                                     userInfo:nil
                                                      repeats:YES];  
}

- (void)changeColor
{
    if (flag == YES)
    {
        self.view.backgroundColor = [UIColor redColor];
        flag = NO;
        return;
    }
    self.view.backgroundColor = [UIColor blueColor];
    flag = YES;

}
like image 168
Naveen Thunga Avatar answered Dec 31 '25 14:12

Naveen Thunga