self.view.backgroundColor=[UIColor colorWithRed:(arc4random()%255)/256 green:(arc4random()%255)/256 blue:(arc4random()%255)/256 alpha:(arc4random()%255)/256];
self.view.backgroundColor=[UIColor colorWithHue:(arc4random()%255)/256 saturation:(arc4random()%128)/256+0.5 brightness:(arc4random()%128)/256+0.5 alpha:1];
這兩個這麼寫對麼,但是只出來一種顏色,他們兩個區別是什麼,怎麼實現背景顏色的閃變呢?
NSTimer *timer =[NSTimer scheduledTimerWithTimeInterval: 0.1 target:self selector:@selector(bigcolor)userInfo:nil repeats:YES];
[timer fire];
-(void)bigcolor
{
self.view.backgroundColor=[UIColor colorWithRed:(float)(arc4random()%255)/256 green:(float)(arc4random()%256)/256 blue:(float)(arc4random()%255)/256 alpha:1];
}