0

I have the following class that I use in order to find the height of a tabBar at the bottom of my screen:

import UIKit

class TabsController: UITabBarController
{
    internal static var tabBarHeight: CGFloat = 0

    override func viewDidLayoutSubviews()
    {
        TabsController.tabBarHeight = self.view.frame.height
        print(TabsController.tabBarHeight)
    }

} 

The only reason I have the class is so that I can access the tabBarHeight variable. I created the class after seeing this post.

For some reason, the print statement displays 667.0 instead of a correct value. How do I get the correct tabbar height?

Community
  • 1
  • 1
Foobar
  • 7,458
  • 16
  • 81
  • 161

1 Answers1

2

If you look back at the answer to that post you will see it is accessing self.tabBar on the UITabBarController, rather than the self.view. The view will encompass the tab bar and it's currently displayed content.

Community
  • 1
  • 1
Dave Barker
  • 155
  • 1
  • 7