Here is how to programmatically set icon / image for Tab Bar Item in UITabBarViewController

Assumptions: I assume you have already embedded in UITabBarViewController for your ViewController in Interface Builder. I also assume you have three tab bar items with individual view controllers and further you have created images assets with your icon images.

Solution is simple you have to copy following code in your current View Controller’s ViewdidLoad method.


self.tabBarController?.tabBar.items?[0].image = UIImage(named: "Icon-1")
self.tabBarController?.tabBar.items?[1].image = UIImage(named: "Icon-2")
self.tabBarController?.tabBar.items?[2].image = UIImage(named: "Icon-3")

Hope it helps,

Thanks & Regards
Mandar Apte

Leave a Reply

Your email address will not be published. Required fields are marked *