Xpre 7.2.1 Swift 2.1.1
您只需要为所需的UITabBarItem设置badgevalue,如下所示:
tabBarController?.tabBar.items?[4].badgevalue = "1" // this will add "1" badge to your fifth tab bar item// or like this to apply it to your first tabtabBarController?.tabBar.items?.first?.badgevalue = "1st"// or to apply to your second tabtabBarController?.tabBar.items?[1].badgevalue = "2nd"// to apply it to your last tabtabBarController?.tabBar.items?.last?.badgevalue = "Last"
要从UITabBarItem中删除徽章,只需为其添加nil值
tabBarController?.tabBar.items?.first?.badgevalue = nil



