Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift - How to change UITabBarItem badge font?

I have a UITabBar. I set a value for tab bar items:

tabBarItem3?.badgeValue = String(self.numberOfProducts)

Now I want to change its font to a specific font. Then I used this code :

tabBarItem3?.setBadgeTextAttributes([NSFontAttributeName: UIFont(name: "IRANSans", size: 14)], for: .normal)

It doesn't work. What should I do?

like image 898
socratesss Avatar asked Jun 10 '17 21:06

socratesss


1 Answers

Swift 3

UITabBarItem.appearance().setBadgeTextAttributes([.font: UIFont.systemFont(ofSize: 30, weight: .medium)], for: .normal)
UITabBarItem.appearance().setBadgeTextAttributes([.font: UIFont.systemFont(ofSize: 30, weight: .medium)], for: .selected)
like image 59
Uday Naidu Avatar answered Nov 08 '22 01:11

Uday Naidu