Skip to content

Instantly share code, notes, and snippets.

@oocoocococo
Created August 3, 2020 22:18
Show Gist options
  • Save oocoocococo/03f34d21f54af74d906c78f1cc96d992 to your computer and use it in GitHub Desktop.
Save oocoocococo/03f34d21f54af74d906c78f1cc96d992 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) {
Text("丸のビュー")
.tabItem {
Image(systemName: selection == .circle ? "circle.fill" : "circle")
.imageScale(.large)
.font(.system(size: 17.0)) // 文字サイズが変わらないようにする
.accessibility(label: Text("丸")) // アクセシビリティラベルをつける
Text("丸のタブ")
}
.tag(Tab.circle)
Text("三角のビュー")
.tabItem {
Image(systemName: selection == .triangle ? "triangle.fill" : "triangle")
.imageScale(.large)
.font(.system(size: 17.0)) // 文字サイズが変わらないようにする
.accessibility(label: Text("三角")) // アクセシビリティラベルをつける
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