隐藏 NSSearchField 的 lupe 图标 [英] Hiding the lupe icon of a NSSearchField

查看:80
本文介绍了隐藏 NSSearchField 的 lupe 图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 NSSearchField(不是子类).当它没有聚焦时, placeholderString 居中.但是左边的lupe图标看起来有点偏移,所以实际上整个事情似乎没有居中.

I’m using a NSSearchField (not subclassed). When it’s not focused, the placeholderString is centered. But the lupe icon on the left appears a bit offset, so in fact the whole thing appears not to be centered.

可以隐藏lupe图标吗?

推荐答案

没有对图标的任何直接访问,因此解决方法是首先访问 NSSearchField 单元格(如图所示),然后访问其按钮单元格.

There is not any direct access to the icon, so that a workaround is first access to the NSSearchField cell (casted as shown), and afterwards access to its button cell.

本例中的self是NSSearchField的一个实例

self in this example is an instance of NSSearchField

[(NSButtonCell *)[(NSSearchFieldCell *)self.cell searchButtonCell] setTransparent:YES];

默认搜索字段:

隐藏/透明图标:

这篇关于隐藏 NSSearchField 的 lupe 图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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