【发布时间】:2011-04-27 09:03:15
【问题描述】:
使用下面的代码,即使我点击他,按钮似乎始终处于正常状态(始终为绿色)。
UIButton *gumb = [UIButton buttonWithType:UIButtonTypeCustom];
gumb.frame = CGRectMake(4, 40, 104, 37);
gumb.tag=0;
[gumb setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[gumb setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
[gumb setBackgroundImage:[UIImage imageNamed:@"greenButton.png"] forState:UIControlStateNormal];
[gumb setBackgroundImage:[UIImage imageNamed:@"whiteButton.png"] forState: UIControlStateSelected];
如果我将正常状态的图像设置为 whiteButton 并将选择的图像设置为 greenButton,则按钮始终为白色,从不为绿色。
【问题讨论】:
-
当你点击按钮时,它会改变状态为highlighted。未选中状态。 Selected 状态用于选项卡按钮
标签: iphone background uibutton