SwiftUIの基本を身につけたい方はこちら

【SwiftUI】SwiftUIでSegmentedControlを作る方法

struct ContentView: View {
    @State var selectedIndex = 0
    
    var body: some View {
        Picker("", selection: $selectedIndex) {
            Text("タグ0")
                .tag(0)
            Text("タグ1")
                .tag(1)
            Text("タグ2")
                .tag(2)
        }.pickerStyle(SegmentedPickerStyle())
    }
}

評価