Hide title from UINavigationBar?

Is there a way to hide the title view in a UINavigationBar?

+5
source share
5 answers

TitleView is a UIView:

titleView A custom view displayed in the center of the navigation bar when this item is the top item.

@property(nonatomic, retain) UIView *titleView

So, I think you can try this:

[titleView setHidden:YES];
+5
source

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

Setting to nil will NOT work as described in the documentation: If this property value is nil, the title of the navigation items is displayed in the center of the navigation bar when the receiver is the top item. If you set this property to a custom title, it is displayed instead of the name.

+12

Another option that saves the back button (as indicated here: fooobar.com/questions/1057146 / ... ):

[self.navigationController.navigationBar setTitleTextAttributes:@{
    NSForegroundColorAttributeName : [UIColor clearColor]
}];
+3
source

For me, the solution in swift should be in my subclass of the navigation bar:

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

With clear color, the title disappears. As described in Josema, you can also do this by accessing the navigation bar of your navigation controller:

self.navigationController!.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.clearColor()]
+1
source

This is what worked for me:

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

All Articles