swift添加进度条, iPhoneX,iOS11 ,电池蓝高度判断

/// 状态栏高度
let JYStatusBarHeight:CGFloat = UIApplication.shared.statusBarFrame.size.height


// 获取appwindow
var JYWindow: UIWindow {
    get {
        if let app = UIApplication.shared.delegate as? AppDelegate {
            return app.window ?? JYWindowView()
        }
        return JYWindowView()
    }
}

/// 判断iPhoneX系列
var isPhoneX: Bool {
    get{
        if #available(iOS 11.0, *) {
            if JYWindow.safeAreaInsets.bottom  > 0 {
                return true
            }
        }
        return false
    }
}

            //  存在导航栏
            if #available(iOS 11.0, *),isPhoneX {
                progressView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 0).isActive = true
                webView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 0).isActive = true
            } else {
                webView.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 0).isActive = true
                progressView.topAnchor.constraint(equalTo: self.view.topAnchor, constant: JYStatusBarHeight).isActive = true
            }

猜你喜欢

转载自www.cnblogs.com/qingzZ/p/11399680.html