If you got a link to tabBarController (e.g. from a UIViewController), you can do the following:
if let tabItems = self.tabBarController?.tabBar.items as NSArray!
{
let tabItem = tabItems[2] as! UITabBarItem
tabItem.badgeValue = "1"
}
From the UITabBarController, it will be:
let tabItems = self.tabBar.items as NSArray!
let tabItem = tabItems[3] as! UITabBarItem
tabItem.badgeValue = "1"
and remove the icon:
tabItem.badgeValue = nil
source
share