2010-10-28 98 views

回答

5

於titleview是一個UIView:

titleview的 在當該 產品的頂部項目的導航欄的中心處顯示的自定義視圖。

@property(nonatomic, retain) UIView *titleView 

所以我認爲你可以試試這個:在文檔描述

[titleView setHidden:YES]; 
+0

什麼是,雖然子視圖? '[nc.navigationItem.titleView setHidden:YES];'不起作用... – 2010-10-28 13:52:34

+0

如果將它設置爲nil,像這樣nc.navigationItem.titleView = nil? – MathieuF 2010-10-28 14:09:12

+0

設置爲零作品! :)感謝 – 2010-11-01 12:34:08

12

self.navigationItem.titleView = [[UIView alloc] initWithFrame:CGRectZero]; self.title = @"Home";

設置爲零將不起作用: 如果該屬性值是零,導航當接收器是頂級項目時,項目的標題顯示在導航欄的中央。如果您將此屬性設置爲自定義標題,則會顯示它而不是標題。

+1

沒有必要爲'self.title = @「Home」;'我不認爲它的部分, – 2013-08-10 16:25:27

+1

它只是起作用。(self.title = @「home」)是不需要的。 – 2013-12-12 09:27:13

3

它保留了後退按鈕(如下回答:https://stackoverflow.com/a/23113326/1156575):另一種選擇

[self.navigationController.navigationBar setTitleTextAttributes:@{ 
    NSForegroundColorAttributeName : [UIColor clearColor] 
}]; 
1

對我來說是我的導航欄子類需要迅速解決辦法:

self.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.clearColor()] 

有了明確顏色標題消失。作爲Josema描述,您還可以通過您的navigationcontroller訪問導航欄做到這一點:

self.navigationController!.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.clearColor()] 
0

這是對我工作:

self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.clear]