我遇到問題。我使用一個按鈕作爲BarButtonItem
。它迄今爲止工作正常,但我的backgroundcolor只有當我點擊我的按鈕時才起作用。我怎樣才能讓我的backgroundcolor每次都會被設置?更改UIButton IPhone的背景顏色
UIButton *redEmergencyButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
redEmergencyButton.frame = CGRectMake(100, 100, 100, 50);
redEmergencyButton.backgroundColor = [UIColor colorWithRed:0.8
green:0.898039215686274509803
blue:1.0
alpha:1.0];
[redEmergencyButton setTitle:@"Emergency"
forState:UIControlStateNormal];
[redEmergencyButton addTarget:self
action:@selector(doEmergency)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rButton = [[UIBarButtonItem alloc]
initWithCustomView:redEmergencyButton];
爲什麼'blue:5.0'? – kennytm 2010-07-20 07:30:21
5倍於1! :) – willcodejavaforfood 2010-07-20 07:46:06
對不起,是藍色的:1.0 – lightwave 2010-07-20 09:21:46