Skip to content

Instantly share code, notes, and snippets.

@osamaqarem
Last active May 17, 2026 18:50
Show Gist options
  • Select an option

  • Save osamaqarem/c264cbdb9e61ff16975c652cf78c4616 to your computer and use it in GitHub Desktop.

Select an option

Save osamaqarem/c264cbdb9e61ff16975c652cf78c4616 to your computer and use it in GitHub Desktop.
Setting the status bar color on different iOS versions
// 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