Set the custom Tabbar and set actions to every tab iOS swift 3


If you want to create a custom tab bar with four buttons and add actions to the tab.Drag the tab bar to the viewController in the bottom side.Then add the tab bar items to the tab bar.first need to add the tab bar delegate to the ViewController.connect the delegate to the tab bar.

class ViewController: UIViewController,UITabBarDelegate{

}

Then implement the did select method for tab bar. Select the tab bar item and set the tag to 0,1,2,3...etc.Then based on the tag below actions will execute.

    func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
        switch item.tag {
        case 0:

//Put the action here
        break
        case 1:

//Put the action here
        break
default:
            break
        }
    }


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift