TonyW
TonyW

Reputation: 18875

In swift: how to add tab bar icons to a regular ViewController storyboard?

I would like to add two tab bar icons (table view and collection view), as shown in the first figure below, to a regular ViewController storyboard (as shown in the second figure).

Tab bar icons

regular ViewController

I have tried to embed the ViewController in the TabBarController (Editor -> Embed in -> Tab Bar Controller), but it seems to me that xcode only allows me to add one icon (Tab Bar Item).

Upvotes: 1

Views: 1569

Answers (2)

ixx
ixx

Reputation: 32273

You need one view controller per tab in the storyboard, then connect the tab view controller to those controllers using "relationship segue", "view controllers" (ctrl-drag from tab view controller to destination controllers, then select that).

In each controller you then can click the tab item and set an image, in attributes.

Upvotes: 1

Akshay Kheveria
Akshay Kheveria

Reputation: 211

add tab bar item to the view controller u want to add in tab bar controller. and then control drag from tab bar view controller and the make "relationship segue as "view controllers"..

Upvotes: 1

Related Questions