iosswiftsafearealayoutguide

How to find out the distance from the bottom safe area edge to the bottom of the screen?


I need to calculate the distance between the bottom anchor of the safe area and the bottom of the screen. Is there a way to do that in code given a view?

enter image description here


Solution

  • Try this one

    if #available(iOS 11.0, *) {
        let window = UIApplication.shared.keyWindow
        let bottomPadding = window?.safeAreaInsets.bottom
    }