小编San*_*ant的帖子

iOS13 中的 iOS TabBar 项目标题问题

我在从 Xcode 11 编译时遇到了 iOS13 的 tabBar 标题问题。它在从 Xcode 10 编译时完美运行。请找到问题的屏幕截图,下面是自定义 tabBar 的代码。

在此处输入图片说明

代码是

self.tabBar.isTranslucent = true
self.tabBar.tintColor = UIColor.white
UITabBarItem.appearance().badgeColor = Constant.Colors.colorFF1744
if #available(iOS 13, *) {
    let appearance = UITabBarAppearance.init()
    appearance.stackedLayoutAppearance.normal.titleTextAttributes = [NSAttributedString.Key.font:UIFont(name: Constant.FontNames.RubikRegular, size: Constant.FontSize.P5heading)!,NSAttributedString.Key.foregroundColor:Constant.Colors.color8D8D8D]
    appearance.stackedLayoutAppearance.selected.titleTextAttributes = [NSAttributedString.Key.font:UIFont(name: Constant.FontNames.RubikRegular, size:Constant.FontSize.P5heading)!,NSAttributedString.Key.foregroundColor:Constant.Colors.colorFF1744]
    appearance.stackedItemPositioning = .automatic
    self.tabBar.standardAppearance = appearance
} else {
    UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font:UIFont(name: Constant.FontNames.RubikRegular, size: Constant.FontSize.P5heading)!, NSAttributedString.Key.foregroundColor:Constant.Colors.color8D8D8D], for: .normal)
    UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font:UIFont(name: Constant.FontNames.RubikRegular, size: Constant.FontSize.P5heading)!, NSAttributedString.Key.foregroundColor:Constant.Colors.colorFF1744], for: .selected)
}
Run Code Online (Sandbox Code Playgroud)

iphone tabbar swift ios13 xcode11

9
推荐指数
2
解决办法
2504
查看次数

标签 统计

ios13 ×1

iphone ×1

swift ×1

tabbar ×1

xcode11 ×1