Before iOS 11 it was common to create views that went edge to edge on the screen, taking up all available space in the glass rectangle of the iOS display. However, from iOS 11 onwards Apple introduced the safe area layout guide, which is a feature that restricts the edges of views so they don’t get clipped by the rounded corners and notch of the iPhone X.
You don’t need to make your view fall inside the safe area, and in fact it’s common to ignore this for background views that should fill the screen behind your content. For example, the built-in Weather app runs its background graphics edge to edge, then puts its main content inside the safe area.
If you use view controller containers such as
UITabBarController they will automatically keep your content clear of the safe area so you don’t need to worry about it. Otherwise, you should switch all your Auto Layout constraints over to the safe area layout guide inside Interface Builder – IB will automatically generate backwards-compatible constraints for older versions of iOS.
Available from iOS
Did this solution work for you? Please pass it on!
Other people are reading…
About the Swift Knowledge Base
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.