【发布时间】:2018-07-12 21:35:15
【问题描述】:
【问题讨论】:
标签: ios iphone swift xcode uitabbarcontroller
【问题讨论】:
标签: ios iphone swift xcode uitabbarcontroller
基本上,当您想以编程方式更改UITabBar 的色调颜色时,UITabBar 类为您提供了几个色调颜色属性:
tintColor:TabBarItem 的颜色。barTintColor : TabBar 的背景栏颜色。unselectedItemTintColor : 未选中项的颜色。所以如果你改变tintColor,barItems的颜色就会改变。
当您在 IB 中为 UITabBar 的项目设置特定颜色时,有一个名为 Image Tint 的选项。
在“查看”部分更改 Tint 选项不会影响 TabBar 的项目,但只有 Image Tint 选项可以更改 tabBar 的项目颜色。
storyboard的全局tint color选项改变了“View”部分的Tint选项,但不影响Image Tint选项的默认值,所以不会影响tab bar的tint颜色。
Image Tint 选项不受影响?我无法解释为什么它不受影响。也许 Apple 遇到了这个问题,或者某种错误。
有一些设置图像颜色的解决方法:
Image Tint 选项。您可能应该设置每个TabBarController 的Image Tint 选项,因为它不会影响全局设置。
在AppDelegate.swift的didFinishLaunchingWithOptions,粘贴以下代码
UITabBar.appearance().tintColor = <#Color what you want#>
【讨论】:
我遇到了类似的问题,已通过将“呈现为”属性更改为“默认”而不是“原始”来解决此问题。在属性检查器的“渲染为”下的右侧选择图像时,您可以在资源库中找到它。
【讨论】: