使用 iOS 5 外观 API 的 UIBarButtonItemStyleDone 背景图像
如何为具有 UIBarButtonItemStyleDone 样式和“编辑/完成”按钮的编辑状态的栏按钮提供视觉上不同的栏按钮项目背景图像? UIBarButtonItem 外观代理的 setBackgroundImage:forState:barMetrics: 中记录的 UIControlState 值似乎都不起作用。
How can I provide a visually distinct bar button item background image for bar buttons with the UIBarButtonItemStyleDone style and the editing state of the Edit/Done button? None of the documented UIControlState values in the UIBarButtonItem appearance proxy's setBackgroundImage:forState:barMetrics: seem to do the trick.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定为什么这个问题从未得到解答,但如果您仍在寻找,那么只需在 .h 中为 BarButtonItem 创建一个属性,在 IB 中分配它,然后设置该 barButtonItem 的背景属性。对我来说效果很好,并且永远不会“变回默认外观”。
I'm not sure why this was never answered but if you are still looking then simply create a property for a BarButtonItem in your .h, assign it in IB, then set the background property of that barButtonItem. Works fine for me and never "changes back to default appearance".
我刚刚找到并发布了该问题的可能解决方案。
您可以使用 UIBarButtonItem 类别“注入”自定义样式:
I have just found and posted a possible solution to this problem.
You can 'inject' custom styles using a UIBarButtonItem category: