0

Tabbar item text is showing truncated on an iPad but on an iPhone it's Working fine.

Here is my Code:

class HomeTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let tabBarAppearnace = UITabBarAppearance()
        let tabFont =  UIFont.boldSystemFont(ofSize: 18)
        
        let selectedAttributes: [NSAttributedString.Key: Any]
        = [NSAttributedString.Key.font: tabFont, NSAttributedString.Key.foregroundColor: UIColor.orange]
        let normalAttributes: [NSAttributedString.Key: Any]
        = [NSAttributedString.Key.font: tabFont, NSAttributedString.Key.foregroundColor: UIColor.black]
        
        tabBarAppearnace.stackedLayoutAppearance.normal.titleTextAttributes = normalAttributes
        tabBarAppearnace.stackedLayoutAppearance.selected.titleTextAttributes = selectedAttributes
        
        //New        
        tabBarAppearnace.inlineLayoutAppearance.normal.titleTextAttributes = normalAttributes
        tabBarAppearnace.inlineLayoutAppearance.selected.titleTextAttributes = selectedAttributes

        tabBarAppearnace.compactInlineLayoutAppearance.normal.titleTextAttributes = normalAttributes
        tabBarAppearnace.compactInlineLayoutAppearance.selected.titleTextAttributes = selectedAttributes


        tabBar.standardAppearance = tabBarAppearnace
    }
}
HangarRash
  • 7,314
  • 5
  • 5
  • 32

1 Answers1

-3
let normalAttrs: [NSAttributedString.Key: Any] = [.foregroundColor: ThemeColor.gray, .paragraphStyle: NSParagraphStyle.default]
let selectedAttrs: [NSAttributedString.Key: Any] = [.foregroundColor: ThemeColor.red, .paragraphStyle: NSParagraphStyle.default]
toyota Supra
  • 3,181
  • 4
  • 15
  • 19
  • Although this code might answer the question, I recommend that you also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes. – Mark Rotteveel Aug 24 '23 at 10:28