Tobias Reich
Tobias Reich

Reputation: 2034

iOS status bar background overlaps UIAlertController

The main view of my app is a scrollable UICollectionView embedded in a UITabBarController. I'm not using a navigation bar and when the user scrolls he sees the cells behind the status bar, because the status bar has no background.

Cells behind status bar

I've used UIApplication.shared.statusBarView?.backgroundColor = .white in my AppDelegate to apply a background and to make the status bar look like desired.

This works fine, but doesn't look nice when you're presenting a UIAlertController.

UIAlertController and status bar background

The white status bar stays above the dimmed background.

Is there a better way to apply a background to the status bar or a way to keep it behind the UIAlertController background?

Upvotes: 0

Views: 305

Answers (1)

Florent Morin
Florent Morin

Reputation: 912

You can try to use a UIView with a background color at the top of your presenting UIView.

Height of status bar can come from UIApplication.shared.statusBarFrame. And update your view size when receiving UIApplication.didChangeStatusBarFrameNotification.

Upvotes: 1

Related Questions