How to add a simple button to the middle of a navigation bar?
i found a lot of topics around placing buttons on navigation bar but none showed me how to place a button at the center of the bar. I found an example with a segmented control but i don't need that.
Just a button instead of the title. Is that possible? ;-)
Edit:
That will do it:
UIButton *titleBut开发者_StackOverflow中文版ton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[titleButton setFrame:CGRectMake(0, 0, 170, 35)];
self.navigationItem.titleView = titleButton;
You can set any custom view (e.g. UIButton) as a titleView
property to your current navigationItem - that should do the trick.
精彩评论