0

I want to change the height of an tab bar. I changed it this way, but no change occurred.

Here's my UITabBarController:

import UIKit
import SideMenu

class TabBarController: UITabBarController {

override func viewDidLoad() {
    super.viewDidLoad()
    setupSideMenu()
    self.navigationController?.navigationBar.isHidden = true

    self.tabBar.frame = CGRect(
        origin: CGPoint(x: 0, y: 20),
        size: CGSize(width: 400, height: 200)
    )
}
Remco Beugels
  • 1,153
  • 1
  • 12
  • 21
Sath.Dev
  • 89
  • 4
  • 18
  • 6
    Even if you make it work this is very dangerous. It might not work (same) on different iOS versions and it might break in later ones. If you really need to change such a property I suggest you create your own tab bar view controller. It is much easier then hacking its appearance. – Matic Oblak Nov 15 '17 at 09:28
  • Possible duplicate of [Change UITabBar height](https://stackoverflow.com/questions/23044218/change-uitabbar-height) – Remco Beugels Nov 15 '17 at 12:20

1 Answers1

2

I am using an extension for changing height of tab-bar

 class CustomHeightTabBar : UITabBar {
        @IBInspectable var height: CGFloat = 0.0

        override func sizeOfTab(_ size: CGSize) -> CGSize {
            var sizeOfTab = super.sizeOfTab(size)
            if height > 0.0 {
                sizeOfTab.height = height
            }
            return sizeOfTab
        }
    }

Assign this class to tab bar

enter image description here

In attribute inspector

enter image description here

It works for me.

NavinBagul
  • 741
  • 7
  • 24