我想显示一个 TextView :
Text("Welcome to iOS 14")
如果用户使用的是 iOS 14。
如果用户使用其他 iOS 版本,我想显示不同的 TextView ,请说:
Text("Welcome to Different iOS version")
我怎样才能实现这一目标?
最佳答案
struct ContentView: View {
var systemVersion = UIDevice.current.systemVersion
var body: some View {
if systemVersion.starts(with: "14" ) {
Text("welcome to ios 14")
} else {
Text("Welcome to Different iOS version")
}
}
}
关于ios - 显示一些 View ,仅适用于 iOS 14、SwiftUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65335960/