How to increase UITabBar height in iOS swift

In this post we will learn how to increase height of UITabBar in UITabBarController using swift programming language. Height of UITabBar cannot be increased either by setting height in interface builder or using a height constraint, only way to achieve it is by writing few lines of code.

Learn how to create UITabBarController programmatically in swift :

Code to increase height of UITabBarController UITabBar

Below is the code with the help of which we can increase height of UITabBarController’s tabbar

 class CustomHeightTabBar: UITabBar {
            override func sizeThatFits(_ size: CGSize) -> CGSize {
                var sizeThatFits = super.sizeThatFits(size)
                sizeThatFits.height = 100.55 //here you can set height as required in your designs
                return sizeThatFits

Here, we created a custom class for our UITabBar named “CustomHeightTabBar” and override sizeThatFits method.

Now, next step is to set this class to our UITabBar. If you are creating UITabBarController programmatically, then you need to tell compiler that set our custom class for UITaBar instead of default UITabBar Class. You can do this simply by adding below line of code.

object_setClass(self.tabBar, CustomHeightTabBar.self)

Where to go from here

In this blog post, we learned with the help of code sample that how can we increase UITabBar height of UItabBarController in swift programming language.