UIViewController Title attribute in Storyboard

后端 未结 10 2128
南旧
南旧 2021-02-03 19:58

I am setting the title field of a UIViewController via Interface Builder/Storyboard: \"enter

10条回答
  •  [愿得一人]
    2021-02-03 20:24

    You can set the title of the UINavigationBar in Storyboard by double clicking the actual navigationBar and typing in a title right there. This only sets the title for the UINavigationBar.

    Setting the title in code offers some different possibilities.

    self.title = @"Your title"; will set the title of a navigationBar and also cause the title to cascade down to a UITabBarItem, if present.

    self.navigationItem.title = @"Your title"; will only set the title of the navigationBar, assuming a UINavigationController is present, and NOT affect a UITabBarItem.

    self.navigationController.title = @"Your title"; will set the title of a UITabBarItem but NOT the UINavigationBar.

提交回复
热议问题