2011-11-14 35 views
4

我必須將ffe1b1的標題顏色設置爲ffe1b1的UIButton.RGB值爲255,225,177。 我正在嘗試此代碼,但它沒有正確反映。我在網上搜索顏色組件漂浮在0.0和1.0之間! 那麼,什麼是給了這RGB Values.ThanksUIButton setTitleColor與RGB值不起作用

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom] ; 
btn.frame = CGRectMake(134.0, 193.0, 80.0, 30.0); 


[btn setBackgroundImage:img forState:UIControlStateNormal]; 
[btn setTitle:@"Contact" forState:UIControlStateNormal]; 

[btn setTitleColor:[UIColor colorWithRed:255.0 green:225.0 blue:177.0 alpha:0.6 ]forState: UIControlStateNormal]; 
+0

只是一個猜測:你有沒有試過將你的值除以256.0? –

回答

10

更改行這樣

[btn setTitleColor:[UIColor colorWithRed:255.0 green:225.0 blue:177.0 alpha:0.6 ]forState: UIControlStateNormal]; 

[btn setTitleColor:[UIColor colorWithRed:(255.0/255) green:(225.0/255) blue:(177.0/255) alpha:0.6 ]forState: UIControlStateNormal]; 
+0

感謝它的工作 – triveni