Reputation: 676
I can get the status bar from UIApplication in normal app by
[UIApplication sharedApplication].statusBarFrame
But we cannot access UIApplication from Extension.Is there a way to find get the statusbar in share?
Upvotes: 8
Views: 946
Reputation: 3905
Alternate Option:
If you're using a view controller with NavigationBar
, you can consider its y
position as the StatusBar
height, in case safeAreaLayoutGuide
and window?.windowScene?.statusBarManager?.statusBarFrame.height
options were not available or usable.
let statusBarHeight = navigationController?.navigationBar.frame.origin.y ?? 0
Upvotes: 0
Reputation: 1586
You may use safeAreaLayoutGuide to calculate layout frame. eg,
viewController.view.safeAreaLayoutGuide.layoutFrame.minY
Upvotes: 1