iOS11 - 安全区域

/// safe aera layout
    static var safeInset: UIEdgeInsets? {
        if #available(iOS 11, *) {
            return UIApplication.shared.keyWindow?.safeAreaInsets
        } else {
            return nil
        }
    }
    
    static var safeInsetTop: CGFloat {
        
        return self.safeInset?.top ?? 0
    }
    
    static var safeInsetBottom: CGFloat {
        return self.safeInset?.bottom ?? 0
    }

你可能感兴趣的:(iOS11 - 安全区域)