Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
现在,我正在使用这段代码:
[btn setTitle:@"disabled" forState:UIControlStateDisabled]; [btn setTitle:@"selected" forState:UIControlStateSelected];
如何让它显示“选定”的文本?我发现它在我使用时并不总是有效
[btn setSelected:YES];.
[btn setSelected:YES];
谁能帮我?提前致谢!!
该代码应该适用于您选择按钮(未突出显示或禁用)或禁用按钮(未突出显示或选择)的简单情况。
请记住,某些控制状态可能会重叠。如果您没有为重叠状态指定图像,则 UIControl 必须选择一个。我不确定确切的算法,但我猜是优先级列表,并且 UIControlStateSelected 的优先级低于 UIControlStateDisabled