前言:
最近看了下SwiftUI一些基礎(chǔ)語(yǔ)法,自己寫了基本的語(yǔ)法,在寫SwiftUI時(shí),不要把OC的思想拿過來(lái)用,完全不同的概念的,swiftUI多協(xié)議,此view非彼view????,寫過swiftUI代碼的童鞋一定會(huì)深有感觸,在此我這有一個(gè)swiftUI思想概念的講解,也在下面這個(gè)地址中,如果想了解,可以下載看下。
另外swiftUI的基本語(yǔ)法我已經(jīng)都寫了一遍,按照蘋果官網(wǎng)來(lái)寫的,地址在此,還在持續(xù)更新中,如果感興趣,童鞋們可以看看撒~~~~
下面直接上代碼,如何改變TabView底部顏色以及tabItem顏色
----- show time -----
//更改TabItem(文本+圖標(biāo))顏色
init() {
UITabBar.appearance().unselectedItemTintColor = UIColor.white
}
更改TabView背景顏色
init() {
UITabBar.appearance().backgroundColor = UIColor.red
UITabBar.appearance().backgroundImage = UIImage()
}
上面的方法親測(cè)有效
整個(gè)Demo代碼如下:
struct TableViewTest: View {
@State private var ff: String = ""
init() {
UITabBar.appearance().backgroundColor = UIColor.purple
UITabBar.appearance().backgroundImage = UIImage()
}
var body: some View {
TabView {
Text("The First Tab")
.tabItem {
Image(systemName: "1.square.fill")
Text("First")
}
.background(Color.green)
Text("Another Tab")
.tabItem {
Image(systemName: "2.square.fill")
//.resizable()
//.frame(width: 20, height: 20, alignment: .center)
Text("Second")
}
Text("The Last Tab")
.tabItem {
Image(systemName: "3.square.fill")
Text("Third")
}
.background(Color.red)
}.accentColor(.green)
.font(.headline)
}
}
后續(xù)會(huì)更新一些swiftUI的問題或者使用過程中遇到的一些有趣的問題,如果童鞋們有問題,可以留言交流哦~