Reputation: 437
I am trying to make a basic iOS device details app. Trying to print the user's iOS version in a view. I have declared a variable in the ContentView.swift file.
var systemVersion = UIDevice.current.systemVersion
But, I do not know how to display this variable to the user via a view in SwiftUI.
Currently:
struct ContentView: View {
@State private var selectedTab = Tab.dash
var body: some View {
TabView(selection: $selectedTab) {
NavigationView {
VStack {
Text("Model Name")
Form {
Section {
Text("iOS") //Display iOSVer around here
Text("Details")
Text("Details")
Text("Details")
Text("Details")
Text("Details")
}
Section {
Text("Details")
Text("Details")
}
}
}
.navigationTitle("Dashboard View")
}
.tabItem {
Image(systemName: "iphone")
Text("Dashboard")
.tag(Tab.dash)
}
Upvotes: 3
Views: 595
Reputation: 257663
You can do it this way
Text("iOS \(UIDevice.current.systemVersion)")
Upvotes: 2