set badgeValue for the desired UITabBarItem as follows:
// for first tab (tabBarController!.tabBar.items!.first! as! UITabBarItem).badgeValue = "1" //for second tab (tabBarController!.tabBar.items![1] as! UITabBarItem).badgeValue = "2" // for last tab (tabBarController!.tabBar.items!.last! as! UITabBarItem).badgeValue = "final"
to remove a badge from UITabBarItem just assign nil
(tabBarController!.tabBar.items!.first! as! UITabBarItem).badgeValue = nil
you can get a result like

for more information, please return the link
Choice - 2
var lbl : UILabel = UILabel(frame: CGRectMake(225, 5, 20, 20)) lbl.layer.borderColor = UIColor.whiteColor().CGColor lbl.layer.borderWidth = 2 lbl.layer.cornerRadius = lbl.bounds.size.height/2 lbl.textAlignment = NSTextAlignment.Center lbl.layer.masksToBounds = true lbl.font = UIFont(name: hereaddyourFontName, size: 13) lbl.textColor = UIColor.whiteColor() lbl.backgroundColor = UIColor.redColor() lbl.text = "1" //if you no need remove this // add subview to tabBarController?.tabBar self.tabBarController?.tabBar.addSubview(lbl)
output

Anbu.karthik
source share