在 iPad 中,我的应用程序的 UITabBaritems 标题文本显示被截断,在 iPhone 中工作正常

问题描述 投票:0回答:1

标签栏项目文本显示被截断。在 iPhone 中工作正常,但在 iPad 中标题文本被截断。

这是我的代码:- 类 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
}

}

ios xcode uitabbaritem
1个回答
0
投票

let normalAttrs: [NSAttributedString.Key: Any] = [.foregroundColor: ThemeColor.gray, .paragraphStyle: NSParagraphStyle.default] 让 selectedAttrs: [NSAttributedString.Key: Any] = [.foregroundColor: ThemeColor.red, .paragraphStyle: NSParagraphStyle.default]

© www.soinside.com 2019 - 2024. All rights reserved.