Get safe area inset top and bottom heights

后端 未结 15 1427
长发绾君心
长发绾君心 2020-11-30 17:30

On the new iPhone X, what would be the most proper way to get both top and bottom height for the unsafe areas?

15条回答
  •  被撕碎了的回忆
    2020-11-30 17:47

    In iOS 11 there is a method that tells when the safeArea has changed.

    override func viewSafeAreaInsetsDidChange() {
        super.viewSafeAreaInsetsDidChange()
        let top = view.safeAreaInsets.top
        let bottom = view.safeAreaInsets.bottom
    }
    

提交回复
热议问题