4

I need to get this appearance of NSSearchField

But it seems to be impossible to set backgroundColor with standard methods of Interface Builder. How i can achieve this? Subclassing NSSearchField and NSSearchFieldCell didn't help, because i loose all animations (when you click on search field and icon+text sliding to left) when implementing my own draw methods.

4

1 回答 1

8

您的屏幕截图显示的只是NSSearchField放置在NSVisualEffectView. 也就是说,当它是NSVisualEffectView(带有materialof NSVisualEffectMaterialLight)的子视图时,搜索字段将自动获得上面的外观。

但是,如果你想要这个没有 的外观NSVisualEffectView,你可以手动设置它的外观:

searchField.appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight];

在此处输入图像描述

于 2015-05-17T14:18:55.850 回答