开发者

How to add a simple button to the middle of a navigation bar?

开发者 https://www.devze.com 2023-02-19 14:02 出处:网络
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 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.

0

精彩评论

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