如何在iOS扩展中获取状态栏高度

guh*_*an0 6 uiviewcontroller uiapplication ios ios8-share-extension share-extension

我可以通过普通应用程序从UIApplication获取状态栏

[UIApplication sharedApplication].statusBarFrame
Run Code Online (Sandbox Code Playgroud)

但我们无法从Extension访问UIApplication.有没有办法在共享中获取状态栏?

Jer*_* Li 1

您可以使用safeAreaLayoutGuide来计算布局框架。例如,

viewController.view.safeAreaLayoutGuide.layoutFrame.minY
Run Code Online (Sandbox Code Playgroud)