user1445205
user1445205

Reputation:

Set background color of NSWindow with appearance set

I am using the following code on my NSWindow so that all my buttons, pop ups, etc. are in a dark mode tint:

[self.window setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]];

But I want to set a custom window background color instead of the black color which is set as default for the Vibrant Dark Appearance. Calling this line without the appearance works otherwise fails to set:

self.window.backgroundColor = [NSColor colorWithPatternImage:[NSImage imageNamed:@"backgroundColor"]];

Any ideas?

Upvotes: 0

Views: 1722

Answers (1)

Guilherme Rambo
Guilherme Rambo

Reputation: 2046

Just add a view with a background color and use It as your window's background.

Take a look at this sample app.

NSWindow with vibrant dark color and background color

Upvotes: 3

Related Questions