Created
February 7, 2024 12:07
-
-
Save technocidal/28847f3da25fd4f6fbe3d70db560ca5d to your computer and use it in GitHub Desktop.
Optional selection
This file contains 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
//: A UIKit based Playground for presenting user interface | |
import UIKit | |
import SwiftUI | |
import PlaygroundSupport | |
struct ContentView: View { | |
@State var selected: Int? = 1 | |
var body: some View { | |
TabView(selection: $selected) { | |
Text("First View") | |
.tabItem { | |
Image(systemName: "1.circle") | |
Text("First") | |
} | |
.tag(Optional(0)) | |
Text("Second View") | |
.tabItem { | |
Image(systemName: "2.circle") | |
Text("Second") | |
} | |
.tag(Optional(1)) | |
Text("Third View") | |
.tabItem { | |
Image(systemName: "3.circle") | |
Text("Third") | |
} | |
.tag(Optional(2)) | |
} | |
.tabViewStyle(.page) | |
} | |
} | |
// Present the view controller in the Live View window | |
PlaygroundPage.current.liveView = UIHostingController(rootView: ContentView()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment