如何在ios13的状态栏上叠加视图

问题描述 投票:5回答:1
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

statusbar ios13
1个回答
0
投票
此代码。...

- (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; } }

© www.soinside.com 2019 - 2024. All rights reserved.