Created
July 20, 2019 11:47
-
-
Save PatrikTheDev/66579dfdc2e8dc7723f3f169137feca8 to your computer and use it in GitHub Desktop.
SegmentedControl as tabs
This file contains hidden or 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
// | |
// 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