How to change the background color of NSSearchField (for example, in the Messages app in OS X)

I need to get this kind of NSSearchField

But setting backgroundColor with standard Interface Builder methods is not possible. How can I achieve this? Subclassing NSSearchField and NSSearchFieldCell did not help as I lost all animations (when you click on the search box and the icon + text moving left) while implementing my own drawing methods.

+3


source to share


1 answer


What your screenshot shows is the default appearance NSSearchField

when placed under NSVisualEffectView

. That is, the search field will automatically look like above if it is a subclass NSVisualEffectView

(with material

of NSVisualEffectMaterialLight

).

However, if you want this appearance without NSVisualEffectView

, you can manually set its appearance:



searchField.appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight];

      

enter image description here

+5


source







All Articles