Programmatically set the icon/image for the Tab Bar Item in UITabBarViewController.

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

Copy the following code using 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

Published by Mandar Apte

Mandar is a Mumbai-based multi-disciplinary designer with UX/UI, Logo, Symbol, and Brand Identity design expertise. He currently runs his Mudrkashar Linguistic Apple iPhone, iPad, and Mac app business in the heart of Mumbai city.

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.