I have great trouble setting background color for NSWindow (Mac OS X) and UIView (iOS) within a method or in a loop. Following code of setting background color only works for the last line of code in loop, which is when all values of i, j, k are 255, as screen turn to white as a proper mixture of RGB.
`- (void) ChangeColorLoop
{
for (int i=0; i<=255; i++)
for (int j=0; j<=255; j++)
for (int k=0; k<=255; k++)
{
[NSThread sleepForTimeInterval: 0.1];
//NSLog(@"%d, %d, %d", i, j, k);
float red = (float) i/255;
float green = (float) j/255;
float blue = (float) k/255;
float alpha = 1.0f;
UIColor *mixedColor = [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
//BackgroundView.backgroundColor = mixedColor;
[BackgroundView setBackgroundColor:mixedColor];
}
}`
Thanks in advance,
Jerry