本文介绍了如何在 iOS 13 中更改状态栏 Alpha?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 iOS 13 中更改状态栏 Alpha.
I want to change the Status Bar Alpha in iOS 13.
let statusBarWindow = UIApplication.shared.value(forKey: "statusBarWindow") as? UIWindow
statusBarWindow?.alpha = 0.5
当我尝试这个时,应用程序崩溃(线程 1:信号 SIGABRT).
When I try this, the app crashes (Thread 1: signal SIGABRT).
推荐答案
您可以参考以下答案来解决您的崩溃问题.
You can refer to the following answer to resolve your crash.
var statusBarUIView: UIView? {
if #available(iOS 13.0, *) {
let tag = 38482458
if let statusBar = self.keyWindow?.viewWithTag(tag) {
return statusBar
} else {
let statusBarView = UIView(frame: UIApplication.shared.statusBarFrame)
statusBarView.tag = tag
self.keyWindow?.addSubview(statusBarView)
return statusBarView
}
} else {
if responds(to: Selector(("statusBar"))) {
return value(forKey: "statusBar") as? UIView
}
}
return nil
}
这些提到的解决方案对我有用.
These mentioned solutions worked for me.
这篇关于如何在 iOS 13 中更改状态栏 Alpha?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!