我试图在TabBar中更改所选选项卡的颜色/uff0c但没有任何效果。 我可以通过编写来改变TabBar backgroundColor
struct ContentView: View {
init() {
UITabBar.appearance().backgroundColor = UIColor.purple
}
var body: some View {
}
}
在swift中/uff0c我们设置了tintColor/uff0c它确实改变了所选标签的颜色。 但是我需要为swiftUI做些什么呢/uff1f
这是我的代码/uff0c
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)
}
方法是/uff1a
使用 accentColor
: https://developer.apple.com/documentation/swiftui/tabview/3368073-accentcolor
TabView {
// fill this out with your tabbed content
}
.accentColor(.orange)
本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/genggaitabbar-swiftuizhongdexuanxiangkaxuanzeyanse.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:8 月 25, 2019 at 06:20 下午