代码之家  ›  专栏  ›  技术社区  ›  Thomas Clayson

向UINavigationBar隐藏标题?

  •  5
  • Thomas Clayson  · 技术社区  · 14 年前

    5 回复  |  直到 9 年前
        1
  •  5
  •   Mathieu Chirag patel    14 年前

    titleView是一个UIView:

    提特列维 一个显示在导航栏中心的自定义视图 项目是最重要的项目。

    @property(nonatomic, retain) UIView *titleView
    

    所以我想你可以试试这个:

    [titleView setHidden:YES];
    
        2
  •  13
  •   marchinram    13 年前

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

    如果此属性值为零,则当接收器为顶部项目时,导航项标题将显示在导航栏的中心。如果将此属性设置为自定义标题,则将显示它而不是标题。

        3
  •  4
  •   Community Fabien Hure    7 年前

    https://stackoverflow.com/a/23113326/1156575 ):

    [self.navigationController.navigationBar setTitleTextAttributes:@{
        NSForegroundColorAttributeName : [UIColor clearColor]
    }];
    
        4
  •  1
  •   Antoine    10 年前

    对我来说,swift中的解决方案需要在我的navigationbar子类中:

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

    随着清晰的颜色标题消失。如Josema所述,您还可以通过从navigationcontroller访问navigationbar来执行此操作:

    self.navigationController!.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.clearColor()]
    
        5
  •  0
  •   Alex Hill    7 年前

    这就是我的工作:

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