Вы не можете добавить более 2 параметров к тернарному оператору ?
. Но вы можете сделать это:
var body: some View {
Text("Hello")
.foregroundColor(amount > 100 ? .red : amount > 20 ? .blue : .white)
}
Или вам придется использовать обычные if else
операторы, например:
var body: some View {
if self.amount > 200 {
return Text("Hello")
.foregroundColor(.blue)
} else if self.amount > 100 {
return Text("Hello")
.foregroundColor(.white)
} else {
return Text("Hello")
.foregroundColor(.black)
}
}