[button setImage: [UIImage imageNamed:@"Back.png"] forState:UIControlStateNormal];
[button setTitle: @"Title" forState:UIControlStateSelected];
我希望按钮以正常状态显示图像,但在选定状态下显示“标题”一词。但我无法让这段代码工作。当我单击按钮进入选定状态并且图像覆盖标题时,它会显示图像。我无法摆脱处于选定状态的图像。
[button setImage: [UIImage imageNamed:@"Back.png"] forState:UIControlStateNormal];
[button setImage: [UIImage imageNamed:@"Back2.png"] forState:UIControlStateSelected];
但这有效。图像从 Back to Back2 翻转。或者其他方式也可以
[button setImage: [UIImage imageNamed:@"Back.png"] forState:UIControlStateSelected];
[button setTitle: @"Title" forState:UIControlStateNormal];
它是如此简单,我开始认为这是 UIButton 错误。
有没有人试过这个?