Skip to content

Instantly share code, notes, and snippets.

@PatrikTheDev
Created July 20, 2019 11:47
Show Gist options
  • Save PatrikTheDev/66579dfdc2e8dc7723f3f169137feca8 to your computer and use it in GitHub Desktop.
Save PatrikTheDev/66579dfdc2e8dc7723f3f169137feca8 to your computer and use it in GitHub Desktop.
SegmentedControl as tabs
//
// SegTab.swift
// SegmentedControlAsTabs
//
// Created by Patrik Svoboda on 20/07/2019.
// Copyright © 2019 Patrik Svoboda. All rights reserved.
//
import SwiftUI
struct SegTab : View {
@State var pageIndex = 0
var body: some View {
VStack
SegmentedControl(selection: $pageIndex) {
Text("Page 1").tag(0)
Text("Page 2").tag(1)
}.padding()
if pageIndex == 0 {
Text("Page 1").font(.largeTitle)
Spacer()
} else {
List {
Text("I am on page 2 and I am in a list.")
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment