2

StatusBar, NavigationBar and TabBar height are diffirent between platforms and orientations.

I would like to know the new height of all three before rotating to change my constraint in the viewWillTransition method.

UIApplication.SharedApplication.StatusBarFrame.Height give the current height.

Any Xamarin or Swift answer would be perfect.

stix
  • 110
  • 10
  • Are you targeting iOS 11/12, or earlier versions? I was composing an answer but was also tailoring it for safe area insets. –  Nov 02 '18 at 14:05
  • iOS 10+. Orientation has change since iOS8 – stix Nov 02 '18 at 15:09
  • Certainly not directly related, but I'm just starting to read about how the new iPads leave differently with screen size (and how the various bar heights) in iOS 12. Also, depending on your Xcode version (and which iOS you are targeting) you may not even *see* the new iPad sizes. Ouch. I'd suggest targeting iOS 11+ to guarantee the safe area insets and changing constraints from there. Here's the link, hope it helps https://medium.com/@hacknicity/how-ipad-apps-adapt-to-the-new-11-and-12-9-ipads-pro-cabd1c0e5f20 –  Nov 02 '18 at 15:47
  • The technique I always used was to monitor for status bar height in `viewWillLayoutSubviews` and update my constraint or position in there. – Brian Nickel Nov 02 '18 at 21:35
  • Thx @Brian but this method will be triggered not only when there is an orientation. – stix Nov 02 '18 at 22:25
  • It might help to know what your goal is or what problem you're facing. It may not be possible to do it in viewWillTransition, so I'm just offering an alternative that might fit your use case. – Brian Nickel Nov 02 '18 at 23:29

0 Answers0