[我在从Xcode 11进行编译时,iOS13的tabBar标题出现问题。在从Xcode 10进行编译时,它可以正常工作。请找到该问题的屏幕截图,以下是自定义tabBar的代码。[在此处输入图像描述] [ 1]
[1]: https://i.stack.imgur.com/zuO6T.png
The code is
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)
}
删除if #available(iOS 13, *)
,并以与iOS 12中相同的方式执行此操作。新方法UITabBatAppearance充满了错误。在固定之前,请避免使用它。