禁用按钮时,UIButton标题消失

时间:2014-07-31 06:07:41

标签: ios uibutton title

当我这样做时,我有一个系统UIButton

self.abutton.enabled = NO;

button’s标题消失了,我不希望它消失我只是希望它不可点击。我该怎么办?

3 个答案:

答案 0 :(得分:2)

yourButton.userInteractionEnabled = NO;

OR

yourButton.enabled = NO;

[yourButton setTitle:@"ButtonDisabled" forState:UIControlStateDisabled];

Check this Apple's documentation

国家/地区列表:

UIControlStateNormal

UIControlStateHighlighted

UIControlStateDisabled

UIControlStateSelected

UIControlStateApplication

UIControlStateReserved

答案 1 :(得分:1)

您是否为按钮的禁用状态添加标题,例如

[YOUR_BTN setTitle:@"xyz" forState:UIControlStateDisabled];

如果不是添加

答案 2 :(得分:1)

根据我的理解,您可以使用以下代码。希望这会对你有所帮助。

   self.aButton.userInteractionEnabled = NO;