I'm looking for the best way to change the backgroundColor
of an NSView
. I'd also like to be able to set the appropriate alpha
mask for the NSView
. Something like:
myView.backgroundColor = [NSColor colorWithCalibratedRed:0.227f
green:0.251f
blue:0.337
alpha:0.8];
I notice that NSWindow
has this method, and I'm not a big fan of the NSColorWheel
, or NSImage
background options, but if they are the best, willing to use.
NSRectFill
usesNSCompositeCopy
to do the fill, so it'll clobber anything behind it—it won't composite on top of any ancestor views. For fills with a partially- (or fully-)transparent color, useNSRectFillUsingOperation
developer.apple.com/mac/library/documentation/Cocoa/Reference/… with theNSCompositeSourceOver
operation. – Licastro