关闭UIBarButtonItem上的突出显示 [英] Turn off highlighting on UIBarButtonItem

查看:108
本文介绍了关闭UIBarButtonItem上的突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用UIBarButtonItem在我的UIToolbar上添加标题。我使用简单的风格,看起来很好,但我似乎无法让它停止突出显示触摸。 突出显示时触摸选项不适用于条形按钮项目。有没有快速简便的方法来做到这一点?我正在尝试在界面构建器中进行构建,以便我可以看到我在做什么。我不想在视图中构建工具栏,每次都加载。

I'm trying to use a UIBarButtonItem to put a title on my UIToolbar. I'm using the plain style and that looks fine, but I can't seem to get it to stop highlighting on touch. The Shows Touch When Highlighted option isn't available for the bar button items. Is there a quick and easy way to do this? I'm trying to do the building in interface builder so I can see what I'm doing. I'd prefer not to build the toolbar in the view did load every time.

推荐答案

负责这个的属性可以在 UIButton 类:

The property responsible for this is accessible in the UIButton class:

myButton.showsTouchWhenHighlighted = NO;

您可以通过将UIButton分配给条形按钮项目的<$来在UIBarButtonItem中以编程方式访问它c $ c> customView 属性,并配置按钮。您也可以在Interface Builder中执行此操作:将UIButton拖到UIToolbar上,它会自动将它嵌入到UIBarButtonItem中 - 然后在按钮的设置下查找显示触摸突出显示复选框。

You can access this (programmatically) in a UIBarButtonItem by assigning a UIButton to the bar button item's customView property, and configuring the button. You can do this in Interface Builder too: drag a UIButton onto a UIToolbar, and it will automatically embed it in a UIBarButtonItem for you - then look for the "Shows Touch On Highlight" checkbox under the button's settings.

顺便说一下,我不知道你是如何自定义你的按钮所以随意忽略这一点,但如果你的按钮看起来像一个标准的工具栏项,那么用户会期望发光效果。

Incidentally, I don't know how you're customising your buttons so feel free to ignore this, but if your button looks and behaves like a standard toolbar item then users will expect the glow effect.

这篇关于关闭UIBarButtonItem上的突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆