【问题标题】:How to overlay a view on the status bar in ios13如何在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

【问题讨论】:

  • 有同样的问题。你找到解决办法了吗?
  • 同样的问题,但首先没有玩窗口。我也看过thisUIWindowScene,但没有运气。有人更新了吗?

标签: statusbar ios13


【解决方案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;
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-24
    • 2020-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多