I'm trying to programatically calculate the height of the top and bottom tool bars in the UIImagePickerController view.
Basically, I'm referring to the black regions that contain the camera controls at the top and the round shutter button at the bottom. Is there a way to do this?
You can do it with the picture ratio. Best photo quality is 3:4, so if it's on this setting, apple adjusts the view so it displays the entire photo while maintaining the aspect ratio. I'm pretty sure you can use that to calculate the height like this:
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
// at current screenwidth, 'previewHeight' is the height necessary to maintain the aspect ratio
CGFloat previewHeight = screenWidth + (screenWidth / 3);
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
CGFloat totalBlack = screenHeight - previewHeight;
CGFloat heightOfBlackTopAndBottom = totalBlack / 2;
NSLog(@"Height is: %f", heightOfBlackTopAndBottom);
It could probably be more optimized, but I think this is more clear for demonstration of what is happening. Also be aware of potential differences in landscape mode.