Hello, getting the statusBarFrame doesn't appear to return the correct value in iOS 11. I realize there may be a nicer way of dealing with this in the future using the Safe Area but right now I really need to get the statusBarFrame to work as it did before iOS 11. Here's how I usually get it.
UIApplication.shared.statusBarFrameI'v verified that my app works properly before iOS 11. But in iOS 11 it appears to be backwards; for example, for an iPhone in portrait it should 20 and in landscape 0. But it returns 0 in portrait and 20 in landscape.
I think it appears to be a timing issue. I wrapped the code that uses the statusBarFrame in a DispatchQueue.main.async {} closure and it works fine. I would consider this more of a bandaid. Still hoping for a proper solution.
Suggestions appreciated.
Thanks!
In the iPhone X simulator after going back from landscape to portait, in viewDidLayoutSubviews I get 44.0 for the height:
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
CGRect statusBarRectConverted = [self.view convertRect:statusBarFrame fromView:nil];During the transition, at least for my little test, viewDidLayoutSubviews is called three times. The first two times the height is 0.0, but the last time viewDidLayotuSubviews gets called the height is 44.0.