在TabBar SwiftUI中更改选项卡选择颜色 [英] Change the tab selection color in TabBar SwiftUI
本文介绍了在TabBar SwiftUI中更改选项卡选择颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更改TabBar中选定选项卡的颜色,但是没有任何效果.我可以通过编写
I am trying to change the color of selected tab in TabBar, but nothing worked. I can change the TabBar backgroundColor
by writing
struct ContentView: View {
init() {
UITabBar.appearance().backgroundColor = UIColor.purple
}
var body: some View {
}
}
迅速设置tintColor
,它确实会更改所选标签的颜色.但是,对于swiftUI,我需要做什么?
In swift, we set tintColor
and it does change the color of selected tab. But what do i need to do for swiftUI?
这是我的代码,
TabView(selection: $selection) {
AView()
.tabItem {
VStack {
Image(systemName: "bubble.left.and.bubble.right")
Text("A Tab")
}
}.tag(0)
BView()
.tabItem {
VStack {
Image(systemName: "house")
Text("B Tab")
}
}.tag(1)
CView()
.tabItem {
VStack {
Image(systemName: "circle.grid.3x3")
Text("C Tab")
}
}.tag(2)
}
对此有任何帮助吗? 在此先感谢!
Any help with this? Thanks in advance!!
推荐答案
这篇关于在TabBar SwiftUI中更改选项卡选择颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文