【发布时间】:2019-12-19 13:41:37
【问题描述】:
fileprivate lazy var netTipWindow:UIWindow = {
let window = UIWindow(frame: CGRect(x: 0, y: topMargins, width: UIScreenW, height: realheight))
window.backgroundColor = .clear
window.windowLevel = .alert
window.isHidden = false
window.rootViewController = UIViewController()
window.rootViewController?.view.addSubview(self)
frame = CGRect(x: 0, y: -(topMargins + realheight), width: UIScreenW, height: realheight)
return window
}()
我的代码在 ios 12 中运行良好,但效果与图片一样。
另外,我试过这段代码,没有区别
fileprivate lazy var netTipWindow:UIWindow = {
let window = UIWindow(frame: CGRect(x: 0, y: topMargins, width: UIScreenW, height: realheight))
window.backgroundColor = .clear
window.windowLevel = .alert
window.isHidden = false
if #available(iOS 13, *) {
window.addSubview(self)
} else {
window.rootViewController = UIViewController()
window.rootViewController?.view.addSubview(self)
}
frame = CGRect(x: 0, y: -(topMargins + realheight), width: UIScreenW, height: realheight)
return window
}()
【问题讨论】:
-
有同样的问题。你找到解决办法了吗?
-
同样的问题,但首先没有玩窗口。我也看过this 和
UIWindowScene,但没有运气。有人更新了吗?