2015-06-29 103 views
1

當用戶按下條形按鈕時,它將其顏色更改爲灰色。但狀態爲pressed時,條形按鈕的顏色不應改變。我有同樣的問題,如this question,永遠不會解決,每個答案都無法正常工作。沒有setUserInteractionEnabled屬性。但禁用整個酒吧按鈕帶來了一個阿爾法效果,我不想要的酒吧按鈕。如何禁用UIBarButtonItem的用戶交互?

有什麼建議嗎?

回答

0

我有類似的問題,我通過設置UIControlStateNormal和UIControlStateDisabled相同的圖像解決它。然後禁用欄按鈕。

UIImage *buttonImage = [UIImage imageNamed:@"ic_launcher.png"]; 
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
[aButton setImage:buttonImage forState:UIControlStateNormal]; 
[aButton setImage:buttonImage forState:UIControlStateDisabled]; 
aButton.frame = CGRectMake(0.0,0.0,50,50); 
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:aButton]; 
backButton.enabled = NO; 
self.navigationItem.leftBarButtonItem = backButton; 
相關問題