Created
July 27, 2020 10:15
-
-
Save oocoocococo/e42264144416ae947d496067333f9306 to your computer and use it in GitHub Desktop.
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 { | |
/// タブの種類 | |
enum Tab { | |
case circle | |
case triangle | |
} | |
/// 選択中のタブ | |
@State private var selection: Tab = .circle | |
var body: some View { | |
TabView(selection: $selection) { | |
Text("丸のビュー") | |
.tabItem { | |
Image(systemName: selection == .circle ? | |
"circle.fill" : // 選択時 | |
"circle") // 非選択時 | |
.imageScale(.large) | |
Text("丸") | |
} | |
.tag(Tab.circle) // タブの種類を指定 | |
Text("三角のビュー") | |
.tabItem { | |
Image(systemName: selection == .triangle ? | |
"triangle.fill" : // 選択時 | |
"triangle") // 非選択時 | |
.imageScale(.large) | |
Text("三角") | |
} | |
.tag(Tab.triangle) // タブの種類を指定 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment