Created
July 21, 2020 00:13
-
-
Save oocoocococo/851630edb3806d6e87e0d9457e083551 to your computer and use it in GitHub Desktop.
SwiftUIのTabViewの色をカスタマイズ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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