如何有条件地修改按钮(或其他 UIView)的 属性?

How do I conditionally modify a button's (or other UIView) property?

场景:

我想切换实体 (UIView) 的 属性;
就像按钮的颜色以及每个 @State 布尔变量的其他特征。

Button(action: {
    self.showActionSheet.toggle()
}) {
    Text("Action Sheet")
    .foregroundColor(Color.white)
}
.padding()
.background(Color.blue)// how do I toggle this conditionally: i.e. one of two colors?
.cornerRadius(10)
.shadow(radius: 10)

正确的做法是什么?

用户三元运算符:

struct ContentView: View {
    @State private var flag = false

    var body: some View {
        Text("Hello")
            .background(flag ? Color.orange : Color.blue)
            .onTapGesture {
                self.flag.toggle()
            }
    }
}