Would anyone happen to know what the default NSBox background/fill color is? It is a gray about 0.9, a little darker than the window background, but I haven't found a matching NSColor name. Is this a standard system color or do I need to roll my own?
Default NSBox background color
Use Digital Color meter to find it (find it with Finder search); it is 227 for all 3 values, so 0.89
If I draw a border, the default fill color is the regular window background. To avoid gymnastics for dark mode, I was just wondering if there was a system color name for it.
I don't know of a system color name for it.
In https://developer.apple.com/documentation/uikit/uicolor
there are only 3 variations of gray
class var darkGray: UIColorA color object whose grayscale value is 1/3 and whose alpha value is 1.0.
A color object whose grayscale value is 2/3 and whose alpha value is 1.0.
What you need is a veryLightGray.
What I usually do is to define it in an extension:
extension UIColor {
public static let mildLightGray = UIColor(red: 0.8, green: 0.8, blue: 0.8, alpha: 1.0)
public static let veryLightGray = UIColor(red: 227/255, green: 227/255,, blue: 227/255,, alpha: 1.0)
}I then use:
let backColor : UIColor = .veryLightGrayI am using Cocoa/Appkit/NSColor, but I was hoping to support dark mode by using system colors. NSColor's label colors were getting there, but at that rate I would need quinary or senary label colors.
Thanks
It is exactly the same for OSX. Just replace UIColor by NSColor …
What is the background color of NSBox in darkmode ?
It's always a good idea to read the AppKit Release Notes: https://developer.apple.com/documentation/appkit/appkit_release_notes_for_macos_10_14
fillColor of a custom NSBox is set to controlBackgroundColor, windowBackgroundColor, or underPageBackgroundColor."