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