3

My custom tab Bar:

class MyTabBar: UITabBar {

}

My custom tab Bar Controller: 

class MyTabBarController: UITabBarController {

}

My question is how I can use my custom tab bar in my custom tab bar controller?

Kampai
  • 22,848
  • 21
  • 95
  • 95
youssef mostafa
  • 308
  • 2
  • 11
  • Possible duplicate of [How do I create a UITabBarController with a custom UITabBar class without using IB?](https://stackoverflow.com/questions/18227378/how-do-i-create-a-uitabbarcontroller-with-a-custom-uitabbar-class-without-using) – Thanh Vu Aug 23 '19 at 01:25

1 Answers1

10

I managed to that by setting the value of 'tabBar' to my custom tabBar.

setValue(MycustomTabBar(frame: tabBar.frame), forKey: "tabBar")

class MyCustomTabBarController: UITabBarController {
override func viewDidLoad() {
        super.viewDidLoad()
        setValue(TBar(frame: tabBar.frame), forKey: "tabBar")
        view.backgroundColor = .white
        createShape()
    }
}
youssef mostafa
  • 308
  • 2
  • 11