Skip to content

Instantly share code, notes, and snippets.

@adamski
Last active September 27, 2019 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamski/9962f69f0cefc5880205629a75f626f4 to your computer and use it in GitHub Desktop.
Save adamski/9962f69f0cefc5880205629a75f626f4 to your computer and use it in GitHub Desktop.
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