Good day! In SwiftUI, is it possible to use a modifier only for a certain os target? In the following code I would like to use the modifier .listStyle(SidebarListStyle()) on
WorkingDog, I try your elegante code with a very simple code to change the text color depending on the Target... but the text stays blue on both target and does not go red on MacOS!
import SwiftUI
struct ContentView: View {
var body: some View {
#if os(macOS)
return monText.foregroundColor(Color.red)
#elseif os(iOS)
return monText.foregroundColor(Color.blue)
#endif
}
var monText: some View {
Text("Hello, World!")
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}