I searched a lot and found out that it is not possible to change tab bar item badge font. So I came out with writing an extension for UITabBarController as follow:
func setCustomBadge(){
removeMyCustomBadge(view: self.tabBar)
setBadgeLabel(view: self.tabBar)
}
func setBadgeLabel(view:UIView){
for subview in (view.subviews){
let myType = String(describing: type(of: subview))
print(myType)
if myType == "_UIBadgeView" {
let customBadeg : UILabel = UILabel(frame: CGRect(x: subview.frame.origin.x, y: subview.frame.origin.y, width: subview.frame.size.width, height: subview.frame.size.height))
customBadeg.font = UIFont(name: "IRANSans", size: 10)
customBadeg.layer.masksToBounds = true
customBadeg.layer.cornerRadius = customBadeg.frame.size.height/2
customBadeg.textAlignment = .center
customBadeg.textColor = UIColor.white
customBadeg.backgroundColor = UIColor(named: "Red")
customBadeg.text = Utility().enNums2Fa(inputString: String(format: "%d", Utility().retrieveUserBasketBadge()))
view.addSubview(customBadeg)
subview.isHidden = true
}
else {
setBadgeLabel(view:subview)
}
}
}
}