// Make text white... and background blue
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[myButton setBackgroundColor:[UIColor blueColor]];
應該用白色文字和藍色背景製作一個按鈕嗎? 它沒有。如何製作帶有白色文字的藍色按鈕?
// Make text white... and background blue
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[myButton setBackgroundColor:[UIColor blueColor]];
應該用白色文字和藍色背景製作一個按鈕嗎? 它沒有。如何製作帶有白色文字的藍色按鈕?
按鈕上的buttonStyle是什麼?這會影響顏色設置的外觀。你可能會嘗試不同的按鈕樣式,直到找到一個看起來不錯的按鈕。
聽起來像你的按鈕是UIButtonTypeRoundedRect
類型。下面的鏈接應該回答你的問題。
Is it even possible to change a UIButtons background color?
什麼,但是我要做的只是不給它一個類型。
UIButton *myButton = [[UIButton alloc] init];
[myButton setBackgroundColor:[UIColor blueColor]];
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
雖然看起來不像那樣花哨。
那麼會發生什麼? – stefanB 2010-03-23 23:18:25
它看起來像一個沒有文字的按鈕。只是按鈕的* CORNERS *變爲藍色。 – Susanna 2010-03-24 00:32:51