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];
这两个这么写对么,但是只出来一种颜色,他们两个区别是什么,怎么实现背景颜色的闪变呢?
X-Code中怎么用UIColor设置背景颜色不停的闪换
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
wx_9999 2014-12-29 06:27关注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];
}
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报