Jor*_*ood 6 interface-builder uitabbarcontroller uitabbaritem ios xcode11
在iOS 13模拟器上使用Xcode 11,beta 2运行UITabBarItems的颜色时,我遇到了问题。但是,当我通过Interface Builder指定自定义的条形颜色时,会得到以下信息:
如果我将Interface Builder中的“ Bar Tint”属性设置为除clear以外的任何选项,则选项卡栏中的所有项目图标均具有选定的颜色。设置为清除时,图标将正确着色。如果我在iOS 12模拟器中编译并运行,这些图标的颜色也会正确显示。
这似乎是Xcode 11中的错误,但也许我遗漏了一些东西?
Sam*_*uël 13
iOS 13中有一个新的外观API。要使用Xcode 11.0为标签栏项目的图标和文本正确着色,您可以像这样使用它:
if #available(iOS 13, *) {
let appearance = UITabBarAppearance()
appearance.backgroundColor = .white
appearance.shadowImage = UIImage()
appearance.shadowColor = .white
appearance.stackedLayoutAppearance.normal.iconColor = .black
appearance.stackedLayoutAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
appearance.stackedLayoutAppearance.selected.iconColor = .red
appearance.stackedLayoutAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red]
self.tabBar.standardAppearance = appearance
}
Run Code Online (Sandbox Code Playgroud)
从表面上看,这似乎是一个错误,但是您可以通过在UITabBar实例上定义一个.unselectedItemTintColor来缓解它。
self.tabBar.unselectedItemTintColor = [UIColor lightGrayColor];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3123 次 |
| 最近记录: |