Search code examples
objective-cnssearchfield

Background color of NSSearchfield not working


I have a NSSearchField and I want to change its background color but i am not able to do it i tried out few things:

1) I tried to set DrawBackground TRUE and then setBackgroundColor but the value of DrawBackGround is always False either I try to set it trough code or Nib.(i don't know why?)

2)I tried out setting NSText's BackgroundColor but it is not looking good because it is not covering whole NSSearchField the extreme corners where the small search icon and cancel icon is present are left uncolored.

3)I want the searchField to have the color of the view it is lying so i decreased the alpha value of the searchField which looks good but the alpha value of text is also decreased so is there any way to make text's alpha value to remain always 1.

Thanks :)


Solution

  • NSSearchField is extension of NSTextField, NSTextField again extension of NSView,

    Not sure, but its possible to make a custom clas and overwrite drawRect function and paint with the background color.