0
我需要幫助!我對此很陌生,我試圖用填充顏色製作UIButton,但每次嘗試創建我的UIColor以填充它時都不起作用。爲什麼我的UIColor不能正確創建?
當我使用:
UIColor *orangeButtonColor = [UIColor blackColor];
UIButton *firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
firstButton.frame = CGRectMake(6, 9, 64, 64);
[firstButton setTitle:@"Select" forState:UIControlStateNormal];
firstButton.backgroundColor = orangeButtonColor;
[self.view addSubview:firstButton];
它給我的屏幕上我的一個黑色按鈕,但我使用RGB顏色要自定義顏色的按鈕(其實CMYK是我的偏好,但我不能使這項工作其一)。所以,我在我的代碼改成這樣:
UIColor *orangeButtonColor = [UIColor colorWithRed:246 green:180 blue:119 alpha:1];
UIButton *firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
firstButton.frame = CGRectMake(6, 9, 64, 64);
[firstButton setTitle:@"Select" forState:UIControlStateNormal];
firstButton.backgroundColor = orangeButtonColor;
[self.view addSubview:firstButton];
再有什麼的屏幕,按鈕剛,只有白色的。我不明白爲什麼我會得到這個問題,但一些幫助將不勝感激!
希望你能仔細閱讀下列文件: http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIColor_Class/Reference/Reference.html#//apple_ref/occ/clm/UIColor/colorWithRed:green:blue:alpha: 這是否告訴你爲什麼你的顏色總是白色? (提示:查看+ colorWithRed部分:綠色:藍色:阿爾法:) – borrrden 2013-05-13 02:58:26