wx_9999 2014-12-25 12:21 采纳率: 100%
浏览 1865
已采纳

X-Code中怎么用UIColor设置背景颜色不停的闪换

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];
这两个这么写对么,但是只出来一种颜色,他们两个区别是什么,怎么实现背景颜色的闪变呢?

  • 写回答

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];

    }

    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?