[英]IOS 13 not making UIWindow with level .statusbar present over status bar of iPhone
I am adding an overlay over the status bar of iphone.我在 iphone 的状态栏上添加了一个覆盖。 But when i switched over to IOS 13.1 on xcode 11.1, I am unable to present it over the status bar using UIWindow class但是当我在 xcode 11.1 上切换到 IOS 13.1 时,我无法使用 UIWindow class 在状态栏上显示它
class PassTroughWindow: UIWindow {
var passTroughTag: Int?
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let hitView = super.hitTest(point, with: event)
if let passTroughTag = passTroughTag {
if passTroughTag == hitView?.tag {
return nil
}
}
return hitView
}
}
class ViewController: UIViewController {
var window: PassTroughWindow?
@IBAction func alertButtonPressed(_ sender: UIButton) {
print("Height : \(UIApplication.shared.statusBarFrame.height)")
print("Height : \(UIApplication.shared.statusBarFrame.maxY)")
let frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: UIApplication.shared.statusBarFrame.maxY)
let banner = UIView(frame: frame)
banner.layer.cornerRadius = 2.5
banner.backgroundColor = UIColor.init(red: 128.0/255.0, green: 161.0/255.0, blue: 193.0/255.0, alpha: 1.0)
let label = UILabel.init(frame: CGRect.init(x: 0, y: 0, width: frame.width, height: frame.height))
label.textAlignment = .center
label.font = .boldSystemFont(ofSize: 10)
label.text = "No internet connection"
label.textColor = .black
banner.addSubview(label)
self.window = PassTroughWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = UIViewController()
self.window?.windowLevel = .statusBar + 1
self.window?.addSubview(banner)
self.window?.makeKeyAndVisible()
self.window?.alpha = 1.0
}
}
The same code if executed in Xcode 11.1 on IOS 13.1 then it gives this result in debugger ():-如果在 IOS 13.1 上的 Xcode 11.1 中执行相同的代码,那么它会在调试器 () 中给出以下结果:-
Whereas, in xcode 10.2 on IOS 12.2 it gives me this result而在 IOS 12.2 上的 xcode 10.2 中,它给了我这个结果
End result in IOS 13.1, Xcode 11.1 is IOS 13.1、Xcode 11.1 的最终结果是
And end result in IOS 12.2, xcode 10.2 is IOS 12.2, xcode 10.2 的最终结果是
How can i present overlay over statubar in IOS 13?如何在 IOS 13 中的状态栏上显示叠加层?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.