如何在UINavigationItem.rightBarButtonItem(或leftBarButtonItem)上添加多个UIBarButton? [英] How do you add more than one UIBarButton on UINavigationItem.rightBarButtonItem (or leftBarButtonItem)?
问题描述
我已经尝试过这种方法/黑客: http://blog.blackwhale.at/2009/06/uibuttons-in- uinavigationbar/
I have tried this approach/hack: http://blog.blackwhale.at/2009/06/uibuttons-in-uinavigationbar/
问题是这留下了淡淡的接缝.我尝试将嵌套工具栏的背景图像设置为我捕获到的应该是的图像.那没用.图像未应用.我还尝试过使用嵌套的UINavigationBar,但这似乎没有用.
The problem is this leaves a faint seam. I tried setting the background image of the nested toolbar to an image I captured of what it should be. That didn't work. The image was not applied. I have also tried using a nested UINavigationBar and that didn't seem to work.
我已经在多个iPhone应用程序中看到了这一点.有人知道吗?
I have seen this done in several iPhone apps. Does anyone know how?
我希望按钮看起来像普通的UIBarButtonItems,并能够使用UIBarButtonSystemItemAdd,UIBarButtonSystemItemRefresh之类的系统样式.我提供的链接可以做到这一点,但是您可以看到一个淡淡的接缝,因为它是嵌套在导航栏中的UIToolbar.
I want the buttons to look like normal UIBarButtonItems and be able to use system styles like UIBarButtonSystemItemAdd, UIBarButtonSystemItemRefresh. The link I provided does this except you can see a faint seam because it is a UIToolbar nested in the navigationbar..
请不要提及这违反了《人机界面指南》. (我们知道).
Please don't mention this breaking the Human Interface Guidelines. (We know).
感谢您为您的黑客做出的贡献……这是实现此目标的唯一方法!
I appreciate you contributing your hacks... thats the only way to do this!
推荐答案
要摆脱UIToolbar的背景(缝"),请创建UIToolbar的子类并重写(void)drawRect:(CGRect)rect方法.将其保留为空白,您的UIToolbar将不再具有背景.
To get rid of the background ('seam') of a UIToolbar, create a subclass of UIToolbar and override the (void)drawRect:(CGRect)rect method. Leave that blank and your UIToolbar will no longer have a background.
只需在我自己的项目中使用它,就可以很好地工作.在以下评论中找到了此内容: http://osmorphis. blogspot.com/2009/05/multiple-buttons-on-navigation-bar.html
Just used this in my own project and worked great. Found this in the comments of: http://osmorphis.blogspot.com/2009/05/multiple-buttons-on-navigation-bar.html
这篇关于如何在UINavigationItem.rightBarButtonItem(或leftBarButtonItem)上添加多个UIBarButton?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!