2014-05-01 112 views
1

我有這樣的事情:的iOS navigationItem.titleView去除利潤率

titleBar_image

但是我需要的是我設置的titleview的觀點,並沒有在左側和右側的邊緣。事情是這樣的:

titleBar_image2

這就是我實際上做:

@property (nonatomic, strong) XHScrollMenu *scrollMenu; // where XHScrollMenu is a subclass of UIView 

- (void)viewdidLoad{ 
_scrollMenu = [[XHScrollMenu alloc] initWithFrame:self.navigationController.navigationBar.frame]; 
_scrollMenu.backgroundColor = [UIColor clearColor]; 
_scrollMenu.delegate = self; 
_scrollMenu.selectedIndex = 0; 
self.navigationItem.titleView =self.scrollMenu; 
} 

我試着用320給人的視圖,但我得到了同樣的結果。我在其他帖子閱讀,也許一個子類的伎倆,但不知道如何實現該解決方案...

我怎樣才能使標題視圖使用整個寬度?

+0

如果有甚至稱爲您發佈的方法,它可能會有所幫助。 – nhgrif

+0

我想你可能會在這個線程中找到解決方案:https://stackoverflow.com/questions/18914812/how-to-edit-empty-spaces-of-left-right-uibarbuttonitem-in-uinavigationbar-ios –

回答

-1

試用bounds而不是frame。看到different between bounds and frame.

...initWithFrame:self.navigationController.navigationBar.bounds] /// or give frame manually such like CGRectMake(x,y,self.view.frame.size.width, yourHeight); 

如果這個建議沒有幫助你的XHScrollMenuinitWithFrame下,然後確定問題。去這個方法,並在那裏檢查。