From 74ad1dd458fdc8c1cb4369137634c44027773a31 Mon Sep 17 00:00:00 2001 From: Kyle Rohr Date: Mon, 16 Sep 2019 16:21:53 -0700 Subject: [PATCH] Add titleTextAttributes property to tab bar item --- .../RAMAnimatedTabBarController.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/RAMAnimatedTabBarController/RAMAnimatedTabBarController.swift b/RAMAnimatedTabBarController/RAMAnimatedTabBarController.swift index 00b889c7..09bb5ff1 100644 --- a/RAMAnimatedTabBarController/RAMAnimatedTabBarController.swift +++ b/RAMAnimatedTabBarController/RAMAnimatedTabBarController.swift @@ -68,6 +68,9 @@ open class RAMAnimatedTabBarItem: UITabBarItem { /// The font used to render the UITabBarItem text. @IBInspectable open var textFontSize: CGFloat = 10 + /// The text attributes to use for the UITabBarItem title + open var titleTextAttributes: [NSAttributedString.Key: Any]? + /// The color of the UITabBarItem text. @IBInspectable open var textColor: UIColor = UIColor.black @@ -350,7 +353,11 @@ open class RAMAnimatedTabBarController: UITabBarController { } textLabel.backgroundColor = UIColor.clear textLabel.textColor = item.textColor - textLabel.font = UIFont.systemFont(ofSize: item.textFontSize) + if let attributes = item.titleTextAttributes { + textLabel.attributedText = NSAttributedString(string: textLabel.text ?? "", attributes: attributes) + } else { + textLabel.font = UIFont.systemFont(ofSize: item.textFontSize) + } textLabel.textAlignment = NSTextAlignment.center textLabel.translatesAutoresizingMaskIntoConstraints = false