从UINavigationBar隐藏标题?
于titleview是一个UIView:
titleview的 在当该 产品的顶部项目的导航栏的中心处显示的自定义视图。
@property(nonatomic, retain) UIView *titleView
所以我认为你可以试试这个:在文档描述
[titleView setHidden:YES];
self.navigationItem.titleView = [[UIView alloc] initWithFrame:CGRectZero]; self.title = @"Home";
设置为零将不起作用: 如果该属性值是零,导航当接收器是顶级项目时,项目的标题显示在导航栏的中央。如果您将此属性设置为自定义标题,则会显示它而不是标题。
没有必要为'self.title = @“Home”;'我不认为它的部分, – 2013-08-10 16:25:27
它只是起作用。(self.title = @“home”)是不需要的。 – 2013-12-12 09:27:13
它保留了后退按钮(如下回答:https://stackoverflow.com/a/23113326/1156575):另一种选择
[self.navigationController.navigationBar setTitleTextAttributes:@{
NSForegroundColorAttributeName : [UIColor clearColor]
}];
对我来说是我的导航栏子类需要迅速解决办法:
self.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.clearColor()]
有了明确颜色标题消失。作为Josema描述,您还可以通过您的navigationcontroller访问导航栏做到这一点:
self.navigationController!.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.clearColor()]
这是对我工作:
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.clear]
什么是,虽然子视图? '[nc.navigationItem.titleView setHidden:YES];'不起作用... – 2010-10-28 13:52:34
如果将它设置为nil,像这样nc.navigationItem.titleView = nil? – MathieuF 2010-10-28 14:09:12
设置为零作品! :)感谢 – 2010-11-01 12:34:08