Changing Tab Bar Item Title and Icon
Using the Story Board:
Select the tab bar item from the corresponding view controller and go to the attributes inspector
If you want a built-in icon and title, set the 'System Item' to the corresponding value.
For a custom icon, add the required images to the assets folder and set the 'System Item' from earlier to 'custom'.
Now, set the icon to be shown when the tab is selected from the 'selected image' drop down and the default tab icon from the 'image' drop down. Add the corresponding title in the 'title' field.
viewDidLoad() method of the view controller, add the following code:
Create an instance
A 'tab bar' is commonly found in most iOS apps and is used to present distinct views in each tab.
To create a tab bar controller using the interface builder, drag a tab bar Controller from the Object Library into the canvas.
By default a tab bar controller comes with two views. To add additional views, control drag from the tab bar controller to the new view and select 'view controllers' in the segue-drop down.
Create Tab Bar controller programmatically without Storyboard
Navigation Controller with TabBar
Navigation controller can be embed in each tabs using storyboard it self. It can be like in the screenshot added.
To add a Navigation Controller to a View Controller connecting from Tab Bar Controller, here are the flow
- Select the view controller for which we need to add navigation controller. Here let it be the Search View Controller as the selection display.
- From the Editor menu of the Xcode, select Embed In -> Navigation Controller option
Tab Bar color customizing
UITabBarController with custom color selection
UITabBarController building in
Swift 3 Change image color and title according to selection with changing selected tab color.
Choosing image for tab bar and set the tab title here
Selection another tab
This modified text is an extract of the original Stack Overflow Documentation created by following contributors
and released under CC BY-SA 3.0