Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用NSSearchField(非子类)。当它不集中时,它placeholderString是居中的。但是左边的 lupe 图标看起来有点偏移,所以实际上整个东西似乎没有居中。
NSSearchField
placeholderString
是否可以隐藏 lupe 图标?
没有对图标的任何直接访问,因此解决方法是首先访问 NSSearchField 单元格(如图所示),然后访问其按钮单元格。
本例中的 self 是 NSSearchField 的一个实例
[(NSButtonCell *)[(NSSearchFieldCell *)self.cell searchButtonCell] setTransparent:YES];
默认搜索字段:
隐藏/透明图标:
Swift3 转换:
(self.cell as! NSSearchFieldCell).searchButtonCell?.isTransparent = true