最佳答案
您可以使用我的解决方案中的 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
}
关于colors - 更改 TabView 中未选中图标的颜色(SwiftUI),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61404684/