Skip to content

Instantly share code, notes, and snippets.

@oocoocococo
Created August 3, 2020 07:36
Show Gist options
  • Save oocoocococo/c5e032e531441bd7f3480592c15699a8 to your computer and use it in GitHub Desktop.
Save oocoocococo/c5e032e531441bd7f3480592c15699a8 to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View {
@State private var selection: Tab = .circle
var body: some View {
// タブビュー
TabView(selection: $selection) {
// ナビゲーションビュー
NavigationView {
Text("丸のビュー")
.navigationBarTitle("丸")
}
.tabItem {
Image(systemName: selection == .circle ? "circle.fill" : "circle")
.imageScale(.large)
Text("丸")
}
.tag(Tab.circle)
// ナビゲーションビュー
NavigationView {
Text("三角のビュー")
.navigationBarTitle("三角", displayMode: .inline)
}
.tabItem {
Image(systemName: selection == .triangle ? "triangle.fill" : "triangle")
.imageScale(.large)
Text("三角")
}
.tag(Tab.triangle)
}
}
}
extension ContentView {
/// タブの種類
enum Tab {
case circle
case triangle
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment