Skip to content

Instantly share code, notes, and snippets.

@oocoocococo
Created July 21, 2020 00:13
Show Gist options
  • Save oocoocococo/851630edb3806d6e87e0d9457e083551 to your computer and use it in GitHub Desktop.
Save oocoocococo/851630edb3806d6e87e0d9457e083551 to your computer and use it in GitHub Desktop.
SwiftUIのTabViewの色をカスタマイズ
struct ContentView: View {
init() {
// 背景色を指定
UITabBar.appearance().barTintColor = UIColor.blue
// 選択していないアイテム色を指定
UITabBar.appearance().unselectedItemTintColor = UIColor.green
}
var body: some View {
TabView() {
Text("丸のビュー")
.tabItem {
Image(systemName: "circle.fill")
Text("丸")
}
Text("三角のビュー")
.tabItem {
Image(systemName: "triangle.fill")
Text("三角")
}
Text("四角のビュー")
.tabItem {
Image(systemName: "square.fill")
Text("四角")
}
}
.accentColor(.yellow) // 選択したアイテム色を指定
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment