Skip to content

Instantly share code, notes, and snippets.

@muskingo muskingo/darkmode.m forked from iccir/darkmode.m
Created Jun 10, 2019

What would you like to do?
iOS Dark Mode Toggle
During Dark Mode migration for macOS, I found it helpful to have a global hotkey
which toggled between Light/Dark Mode.
This hack attempts to do something similar for iOS.
1) Add your main window in -applicationDidFinishLaunching:
2) Triple tap the window (I tend to do this near the title bar) to flip between light and dark.
@interface UIApplication ()
+ (void) _setDebugUserInterfaceStyleOverride:(NSInteger)override;
@implementation UIApplication (IccirDebugUserInterfaceStyleOverride)
- (void) iccirToggleDebugUserInterfaceStyleOverride
static NSInteger sOverride = 0;
sOverride = sOverride == 1 ? 2 : 1;
[UIApplication _setDebugUserInterfaceStyleOverride:sOverride];
void AddInterfaceStyleToggle(UIWindow *window)
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] init];
[recognizer setNumberOfTapsRequired:3];
[recognizer addTarget:[UIApplication sharedApplication] action:@selector(iccirToggleDebugUserInterfaceStyleOverride)];
[window addGestureRecognizer:recognizer];
void AddInterfaceStyleToggle(UIWindow *window) { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.