0
所以我有一个标签,我希望能够按下我已设置的按钮并更改标签的RGB值。看起来很简单,但我很难过。有任何想法吗?随机化标签的颜色
NSInteger r = arc4random()%255;
NSInteger g = arc4random()%255;
NSInteger b = arc4random()%255;
_label.textColor= [UIColor colorWithRed:(arc4random_uniform(r/255.0)) green:(arc4random_uniform(g/255.0)) blue:(arc4random_uniform(b/255.0)) alpha:1] ;
什么是'(arc4random_uniform(r/255.0))'部分应该做的?不是'r'已经是随机的吗? – Undo
另外,什么具体不工作? – Undo
标签颜色不会按预期更改。我知道按钮连接正确,因为我已经用[UIColor greenColor] – foo