Hi there,
I am currently developing an app with a tab view. Unfortunately some the symbols I use only work for iOS 17. I would like to change a symbol but only for iOS 16. Is this possible? Thank you for your help!
Laurin
Here is my code:
struct ContentView: View {
var body: some View {
TabView {
Group {
Medikamente()
.tabItem {
Image(systemName: "syringe")
Text("Medikamente")
}
BPR()
.tabItem {
Image(systemName: "point.bottomleft.forward.to.arrowtriangle.uturn.scurvepath")
Text("BPR")
}
InvasiveMassnahmen()
.tabItem {
Image(systemName: "heart.text.square")
Text("Maßnahmen")
}
}
}
}
}
#Preview {
ContentView()
}
Here's one way of doing it:
struct ContentView: View {
var body: some View {
if #available(iOS 17, *) {
// If iOS 17 or greater is in use, these symbols will be used
let kSymbolMedikamente: String = "syringe"
let kSymbolBPR: String = "point.bottomleft.forward.to.arrowtriangle.uturn.scurvepath"
let kSymbolInvasiveMassnahmen: String = "heart.text.square"
} else {
// Anything lower than iOS 17 will use these symbols
let kSymbolMedikamente: String = "syringe"
let kSymbolBPR: String = "point.bottomleft.forward.to.arrowtriangle.uturn.scurvepath"
let kSymbolInvasiveMassnahmen: String = "heart.text.square"
}
TabView {
Group {
Medikamente()
.tabItem {
Image(systemName: kSymbolMedikamente)
Text("Medikamente")
}
BPR()
.tabItem {
Image(systemName: kSymbolBPR)
Text("BPR")
}
InvasiveMassnahmen()
.tabItem {
Image(systemName: kSymbolInvasiveMassnahmen)
Text("Maßnahmen")
}
}
}
}
}