Skip to content

Instantly share code, notes, and snippets.

@adamski
Last active Sep 27, 2019
Embed
What would you like to do?
OSXUIUtils
#pragma once
#ifdef __APPLE__
struct OSXUIUtils
{
static void setDarkTheme(void* view);
};
#endif
#include "OSXUIUtils.h"
#import <AppKit/AppKit.h>
void OSXUIUtils::setDarkTheme(void* view)
{
NSView* nsView = (NSView*)view;
NSWindow* nsWindow = [nsView window];
NSAppearance* appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark];
[nsWindow setAppearance:appearance];
}
@adamski
Copy link
Author

adamski commented Sep 27, 2019

Usage from a JUCE app:

        mainWindow.reset (new MainWindow (getApplicationName()));

#if JUCE_MAC
        auto* windowHandle = mainWindow->getWindowHandle();
        OSXUIUtils::setDarkTheme(windowHandle);
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment