我正在嘗試使用自定義圖像爲我的導航欄創建按鈕。當我運行下面的代碼時,該按鈕就像它應該顯示的那樣,除了你可以在它後面看到另一個更寬的按鈕,伸出兩側。我如何擺脫其他按鈕?自定義按鈕initWithImage在自定義圖像後面顯示默認按鈕
UIBarButtonItem *emailButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"emailBut"]
style:UIBarButtonSystemItemCompose
target:self
action:@selector(emailSheet)];
self.navigationItem.rightBarButtonItem = emailButton;
我試着將它改爲純色和邊框,圖像後面的按鈕仍然存在,大小相同,只是顏色不同。 – Mirror318 2012-08-07 02:43:06
如果你指的是這個邊框,你應該使用'UIButton'而不是'UIBarButtonItem'。 – aforaudrey 2012-08-07 03:17:41