我正在尝试使用新的swiftui框架更改tabView外观。我尝试了这个:

appearance.stackedLayoutAppearance.normal.titleTextAttributes = [NSAttributedString.Key.font: UIFont(name: "Lato-Regular", size: 11)!]
appearance.stackedLayoutAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: Color.TabViewItemNormalColor.uiColor()]

appearance.stackedLayoutAppearance.selected.titleTextAttributes = [NSAttributedString.Key.font: UIFont(name: "Lato-Regular", size: 11)!]
appearance.stackedLayoutAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: Color.TabViewItemNormalColor.uiColor()]


但是只改变了文字颜色,字体与以前一样

最佳答案

尝试以下

appearance.stackedLayoutAppearance.normal.titleTextAttributes = [
    NSAttributedString.Key.font: UIFont(name: "Lato-Regular", size: 11)!,
    NSAttributedString.Key.foregroundColor: Color.TabViewItemNormalColor.uiColor()
]

appearance.stackedLayoutAppearance.selected.titleTextAttributes =  [
    NSAttributedString.Key.font: UIFont(name: "Lato-Regular", size: 11)!,
    NSAttributedString.Key.foregroundColor: Color.TabViewItemNormalColor.uiColor()
]

关于ios - 更改TabBar外观,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59302679/

10-13 08:17