【发布时间】:2020-04-24 08:58:50
【问题描述】:
【问题讨论】:
【问题讨论】:
您可以使用我的解决方案中的TabBarAccessor 到Programmatically detect Tab Bar or TabView height in SwiftUI 来更改您需要的内容,如下面的演示所示。
使用 Xcode 11.4 / iOS 13.4 测试
TabView {
Text("First View")
.background(TabBarAccessor { tabBar in
tabBar.unselectedItemTintColor = UIColor.red
})
.tabItem { Image(systemName: "1.circle") }
.tag(0)
Text("Second View")
.tabItem { Image(systemName: "2.circle") }
.tag(1)
}
更新:通过外观替换也可以使用
init() {
UITabBar.appearance().unselectedItemTintColor = UIColor.green
}
【讨论】: