开发者

Add a UIButton to UINavigationController programmatically

开发者 https://www.devze.com 2023-01-19 06:51 出处:网络
In Interface Builder you can drag a UIButton to the centre of a Navigati开发者_开发百科on Controller, between the rightButtonItem and leftButtonItem.

In Interface Builder you can drag a UIButton to the centre of a Navigati开发者_开发百科on Controller, between the rightButtonItem and leftButtonItem.

I would like to do this programmatically, as i am not loading a xib.

I tried:

[self.navigationItem addSubview:myButton] // no luck
[self.navigationController.navigationBar addSubview:myButton] //no luck

Thanks


Set the titleView of the UINavigationItem for the view controller you want the button to appear with.

[myAddedViewController.navigationItem setTitleView:myButton]
0

精彩评论

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

关注公众号