Swift中的状态栏高度 [英] Status bar height in Swift

查看:560
本文介绍了Swift中的状态栏高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Swift中以编程方式获取状态栏的高度?

How can I get the status bar's height programmatically in Swift?

在Objective-C中,它是这样的:

In Objective-C, it's like this:

[UIApplication sharedApplication].statusBarFrame.size.height.


推荐答案

Swift 2是否有任何问题。 x

UIApplication.sharedApplication().statusBarFrame.size.height

Swift 3或Swift 4

UIApplication.shared.statusBarFrame.height

确保 UIKit 已导入

import UIKit

这篇关于Swift中的状态栏高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆