开发者

How to customize the top bar of a UINavigationController with the current view information?

开发者 https://www.devze.com 2023-03-01 13:23 出处:网络
I\'ve a UINavigationControlle开发者_高级运维r and in the picture you can see a UIViewController added to it.

I've a UINavigationControlle开发者_高级运维r and in the picture you can see a UIViewController added to it.

Now, I would like to customize the top bar of the UINavigationController with the content of the current visible UIViewController. More in particular, I would like:

  1. add the title
  2. customize "back" button text

Should I use self.navigationController method from the current UINavigationController ? If so, what are the next steps ?

Thanks

How to customize the top bar of a UINavigationController with the current view information?


You can set the Title with:

[[self navigationItem] setTitle:@"title text"];

You can change the backbuttontext in the InterfaceBuilder or:

[[[self navigationItem] backBarButtonItem] setTitle:@"back button text"];

But remember that the backBarButtonItem comes from the previous ViewController so you have to set it there. Alternatively the title is set from the previous view.


self.title = "Your title";

You can use this in the current view controller for displaying title

0

精彩评论

暂无评论...
验证码 换一张
取 消