I'm writing an app that uses UITabBar for parts of the navigation. I'm also using UIScrollView for presenting more information than what the screen can typically handle. Because of this, I'm needing to set the scroll view to take into account the height of the UITabBar so that all of the information is displayed.

Is there a way to calculate the height of the UITabBar?


If the view controller has an ancestor that is a tab bar controller, you can retrieve the height from that tab bar.

CGFloat tabBarHeight = self.tabBarController.tabBar.frame.size.height;

It is 320 x 49.

If you want to test, open Interface Builder, add a UITabBar, go into the ruler, you will see it

UITabBar is inherited from UIVIew so you can use the frame.size.height to get the height


In Swift:

let height = self.tabBarController?.tabBar.frame.height ?? 49.0

Relying on the actual height of the tab-bar, and using the magic number as a fallback.