Is it possible to query (programmatically, at runtime) what the height/thickness of a navigation bar and/or toolbar will be post-rotation?
That is, when building a frame for a specific subview, I want to set its frame relative to the available space between the navigation bar and the toolbar. To make it smooth, it's best to do this in shouldAutorotateToInterfaceOrientation:
rather than didRotateFromInterfaceOrientation:
, but values such as self.navigationController.toolbar.frame.size.height
are different between orientations and devices.
I'd like to calculate my new subview frame against what the toolbar's thickness will be, and I'd like to do it without hardcoding values such as 32pt, 44pt, etc.
Any thoughts?
You should do all your frame resizing in willAnimateRotationToInterfaceOrientation:duration:
AFAIK there is no way to predict the size of your UIViews until you reach didRotateFromInterfaceOrientation:
One way could be to do all the frames resizing in your code, including the toolbar. That way you have full control over the size of your UI elements.
You can change your views frame in willAnimateRotationToInterfaceOrientation:duration:
method.
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
NSLog(@"%@", NSStringFromCGRect(self.navigationController.navigationBar.frame));
}
For more information take a look at the documentation provided by Apple.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With