如何在iOS 13中获取状态栏的高度? [英] How to get the status bar height in iOS 13?
本文介绍了如何在iOS 13中获取状态栏的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在iOS 13中UIApplication.shared.statusBarFrame.height
警告
在iOS 13.0中不建议使用'statusBarFrame':使用statusBarManager 而是窗口场景的属性.
'statusBarFrame' was deprecated in iOS 13.0: Use the statusBarManager property of the window scene instead.
如何在不使用iOS 13中已弃用的API的情况下获得状态栏的高度?
How do you get the status bar height without using a deprecated API in iOS 13?
推荐答案
作为警告提示,您可以访问具有statusBarFrame
属性的statusBarManager
.这是在您的UIWindow
的windowScene
上定义的.
As the warning hints, you can access the statusBarManager
which has a statusBarFrame
property. This is defined on your UIWindow
's windowScene
.
let height = view.window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0
这篇关于如何在iOS 13中获取状态栏的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文