extension UIApplication {
	class func getsafeAreaBottomMargin() -> CGFloat {
        if #available(iOS 11.0, *) {
            let currentwindow = UIApplication.shared.windows.first
            return (currentwindow?.safeAreaLayoutGuide.owningView?.frame.size.height)! - (currentwindow?.safeAreaLayoutGuide.layoutFrame.size.height)! - (currentwindow?.safeAreaLayoutGuide.layoutFrame.origin.y)!
        }
        else {
            return 0
        }
    }
    
    class func getsafeAreaTopMargin() -> CGFloat {
        if #available(iOS 11.0, *) {
            let currentwindow = UIApplication.shared.windows.first
            return currentwindow?.safeAreaInsets.top ?? 0.0
        }
        else {
            return 0
        }
    }
    
    class func getsafeAreaLeftMagin() -> CGFloat {
        if #available(iOS 11.0, *) {
            let currentwindow = UIApplication.shared.windows.first
            return currentwindow?.safeAreaInsets.left ?? 0.0
        }
        else {
            return 0
        }
    }
    
    class func getsafeAreaRightMagin() -> CGFloat {
        if #available(iOS 11.0, *) {
            let currentwindow = UIApplication.shared.windows.first
            return currentwindow?.safeAreaInsets.right ?? 0.0
        }
        else {
            return 0
        }
    }
}

사용방법

let safeTop = UIApplication.getsafeAreaTopMargin()
let safeBottom = UIApplication.getsafeAreaBottomMargin()

+ Recent posts