Custom Tab Bar Swift Ios With Code Examples

  • Updated
  • Posted in Programming
  • 4 mins read

Custom Tab Bar Swift Ios With Code Examples

Hello everybody, on this submit we’ll have a look at the right way to resolve the Custom Tab Bar Swift Ios downside within the programming language.

class CustomTabBarController: UITabBarController {

    override func viewDidLoad() {

        let controller1 = UIViewController()
        controller1.tabBarMerchandise = UITabBarMerchandise(tabBarSystemItem: .contacts, tag: 1)
        let nav1 = UINavigationController(rootViewController: controller1)

        let controller2 = UIViewController()
        controller2.tabBarMerchandise = UITabBarMerchandise(tabBarSystemItem: .contacts, tag: 2)
        let nav2 = UINavigationController(rootViewController: controller2)

        let controller3 = UIViewController()
        let nav3 = UINavigationController(rootViewController: controller3)
        nav3.title = ""

        let controller4 = UIViewController()
        controller4.tabBarMerchandise = UITabBarMerchandise(tabBarSystemItem: .contacts, tag: 4)
        let nav4 = UINavigationController(rootViewController: controller4)

        let controller5 = UIViewController()
        controller5.tabBarMerchandise = UITabBarMerchandise(tabBarSystemItem: .contacts, tag: 5)
        let nav5 = UINavigationController(rootViewController: controller5)

        viewControllers = [nav1, nav2, nav3, nav4, nav5]

    func setupMiddleButton() {
        let menuButton = UIButton(body: CGRect(x: 0, y: 0, width: 64, top: 64))
        var menuButtonFrame = menuButton.body
        menuButtonFrame.origin.y = - - 50
        menuButtonFrame.origin.x = view.bounds.width/2 - menuButtonFrame.dimension.width/2
        menuButton.body = menuButtonFrame

        menuButton.backgroundColor = UIColor.crimson
        menuButton.layer.cornerRadius =

        menuButton.setImage(UIImage(named: "instance"), for: .regular)
        menuButton.addTarget(self, motion: #selector(menuButtonAction(sender:)), for: .touchUpInaspect)


    // MARK: - Actions

    @objc personal func menuButtonAction(sender: UIButton) {
        chosenIndex = 2


As we’ve seen, plenty of examples have been used to deal with the Custom Tab Bar Swift Ios downside.

How do I create a customized tab bar in Swift?

Call the addChild technique of the TabBar .We wish to:

  • Implement a view controller that may maintain another view controllers.
  • Show a kind of view controllers.
  • Show a tab bar on the backside of the display over the proven view controller.
  • Switch between the assorted view controllers when the consumer faucets on a tab bar button.

How do I put the highest tab bar in Swift?

5 Answers

  • Swift 2.X self.tabBar.body = CGRectMake(0,0,320,50) //instance for iPhone 5.
  • Swift 3.X self.tabBar.body = CGRect(0,0,320,50) //instance for iPhone 5.
  • Swift 4.X self.tabBar.body = CGRect( x: 0, y: 0, width: 320, top: 50) //instance for iPhone 5.

How do I add a tab bar to an merchandise?

To add a tab, first drag a brand new View Controller object to the storybard. Next control-drag from the tab bar controller to new view controller and choose view controllers underneath Relationship Segue . Your tab bar controller will replace with a brand new tab.

How do I create a tabBar in swift 5?

To add a Tab Bar Controller to the Storyboard, choose the 4 placeholders that we simply created and the View Controller. Then, go to Editor, choose Embed in and Tab Bar Controller. This will envelop all these scenes in a single Tab Bar Controller. Put the brand new Tab Bar Controller on prime of the opposite controllers.

How do I create a customized tab?

  • From Setup, within the Quick Find field, enter Tabs , then choose Tabs.
  • Click New within the Custom Object Tabs associated listing.
  • Select the customized object to look within the customized tab.
  • Click the Tab Style lookup icon to point out the Tab Style Selector.
  • Click a tab type to pick out the colour scheme and icon for the customized tab.

How do I create a customized ribbon tab?

To customise the Ribbon, open or create an Excel, Word, or PowerPoint doc. Go to the app Preferences and choose Ribbon and Toolbar. On the Ribbon tab window, choose the instructions you wish to add or take away out of your Ribbon and choose the add or take away arrows.

How do you place a Tab on prime of IOS?

In the menu that seems, faucet Arrange Tabs By, then select an possibility. Or, contact and maintain the tab, then drag it the place you need it.

How do I add a Tab bar to my Storyboard?

How do I set Tabs in XCode?


  • Within XCode, choose Preferences from the primary menu or press Command-,.
  • Under the tabs, you will discover a left-right scroll bar. Scroll proper and choose Indentation.
  • Under Tabs, examine “Tab key inserts tabs, not areas.
  • In the Tab width discipline, enter 2.
  • In the Indent width discipline, enter 2.

How do I present my tab bar?

To toggle the visibility of the Tab Bar, both:

  • Open Settings > Tabs and untick the field for Show Tab Bar to cover it. Tick the field once more to point out the Tab Bar;
  • Open the. Vivaldi Menu > View > Show Tab Bar.
  • Type “Tab Bar” in Quick Commands;
  • Set a Keyboard Shortcut or a Mouse Gesture for toggling the Tab Bar’s visibility.

Leave a Reply