Last active
May 17, 2026 18:50
-
-
Save osamaqarem/c264cbdb9e61ff16975c652cf78c4616 to your computer and use it in GitHub Desktop.
Setting the status bar color on different iOS versions
This file contains hidden or 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
| // Handling status bar color | |
| UIColor *statusBarColor = [UIColor colorWithRed:0.84 green:0.13 blue:0.19 alpha:1.0]; | |
| if (@available(iOS 13.0, *)) { | |
| UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame]; | |
| statusBar.backgroundColor = statusBarColor; | |
| [[UIApplication sharedApplication].keyWindow addSubview:statusBar]; | |
| }else{ | |
| UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"]; | |
| if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) { | |
| statusBar.backgroundColor = statusBarColor; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment