如何在ios13的状态栏上叠加视图
Posted
技术标签:
【中文标题】如何在ios13的状态栏上叠加视图【英文标题】:How to overlay a view on the status bar in ios13 【发布时间】: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
()
iOS 13 status bar
【问题讨论】:
有同样的问题。你找到解决办法了吗? 同样的问题,但首先没有玩窗口。我也看过this 和UIWindowScene
,但没有运气。有人更新了吗?
【参考方案1】:
这段代码....
- (BOOL)prefersStatusBarHidden
if (@available(iOS 13.0, *))
// safearea iPhone x, xr ..
if ([[[UIApplication sharedApplication] delegate] window].safeAreaInsets.top > 20.0)
return NO;
else
return YES;
else
return NO;
【讨论】:
以上是关于如何在ios13的状态栏上叠加视图的主要内容,如果未能解决你的问题,请参考以下文章