iPhone:如何在按下时从UIBarButtonItem中删除发光(光)? [英] iPhone: How to remove glow (light) from UIBarButtonItem when pressed?
问题描述
我正在尝试从UIBarButton项目中删除光晕,以便我的文本看起来是标签而不是按钮。我已经看过各种帖子谈论如何通过界面构建器或通过设置布尔变量showsTouchWhenHighlighted来做到这一点,但这些选项都不可用于我看来。我已尝试在.m viewDidLoad中设置showsTouchWhenHighlighted,我在其中更改了字体和字体大小,但UIBarButtonItem似乎没有该属性。我也只在下面的图像中有选项在InterfaceBuilder中进行更改。
I'm trying to remove the glow from a UIBarButton item so that my text appears to be a label instead of a button. I've seen various posts talking about how to do this through interface builder or by setting a boolean variable "showsTouchWhenHighlighted", but neither of these options are available to me it appears. I've tried setting the showsTouchWhenHighlighted in the .m viewDidLoad where I change the font and font-size but the UIBarButtonItem doesn't appear to have that property. I also only have the options in the following image to change in InterfaceBuilder.
推荐答案
有一种方法可以做到这一点(有点黑客但它有效)。只需将 UIButton
拖到工具栏中(而不是 UIBarButtonItem
)。然后将自动为您创建 UIBarButtonItem
作为 UIButton
的超级视图。然后你就这样设置:
There is a way to do this (a bit of a hack but it works). Just drag a UIButton
into your toolbar (instead of a UIBarButtonItem
). Then a UIBarButtonItem
will be automatically be created for you as a superview for your UIButton
. Then you just set it like this:
UIBarButtonItem
- 风格:普通
- 标题:(空)
UIButton
- 类型:自定义
- 标题:(您的实际标签标题)
- 文字颜色:白色
- 显示触摸突出显示:(未选中)
- Type: Custom
- Title: (your actual label title here)
- Text Color: White
- Shows Touch On Highlight: (Unchecked)
以下是用作参考的屏幕截图:
Here is a screenshot to use as reference:
注意:请记住,从现在开始,必须在 UIButton
Note: Just remember that from now on any updates on the text must be made on the UIButton
这篇关于iPhone:如何在按下时从UIBarButtonItem中删除发光(光)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!