How to get safe area top and bottom insets in Swift 5

After iOS13 keyWindow concept in iOS anymore as a single app can have multiple windows. So just take the first one :

    let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
    let topPadding = window?.safeAreaInsets.top
    let bottomPadding = window?.safeAreaInsets.bottom
    

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top