Last active
July 15, 2020 17:58
-
-
Save michaelpeternell/27229b3fe9ab31ac4b34 to your computer and use it in GitHub Desktop.
Change the text color of the status bar on iPhone and iPad (works for iOS 7 - iOS 12)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// sets the status bar text color. returns YES on success. currently, this only | |
/// works in iOS 7. It uses undocumented, inofficial APIs. | |
BOOL setStatusBarColor(UIColor *color) | |
{ | |
id statusBarWindow = [[UIApplication sharedApplication] valueForKey:@"statusBarWindow"]; | |
id statusBar = [statusBarWindow valueForKey:@"statusBar"]; | |
SEL setForegroundColor_sel = NSSelectorFromString(@"setForegroundColor:"); | |
if([statusBar respondsToSelector:setForegroundColor_sel]) { | |
// iOS 7+ | |
[statusBar performSelector:setForegroundColor_sel withObject:color]; | |
return YES; | |
} else { | |
return NO; | |
} | |
} |
this no longer works with iOS 13 :-(
In iOS 13, the status bar is rendered by a system process and we therefore cannot "customize" it anymore.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Disclaimer: please note that including this code into your app will probably prevent it from being approved by the app store. Don't say I didn't warn you!