【发布时间】:2019-11-02 14:42:13
【问题描述】:
在 SwiftUI 中,我在视图中有一个按钮:
Button(action: {self.isMatrimonioOn.toggle()}) {
Image(!isMatrimonioOn ? "imageA" : "imageA_color")
}
当用户按下按钮时,它会改变颜色(imageA-> imageA_color),同时图像(imageA_Color 本身)必须出现在另一个视图的单元格中。应该如何设置功能?
谢谢,但我还没有成功。我想是这样说的,但是当按下按钮时它不会改变图像。
@Binding var isMatrimonioOn : Bool
var body: some View {
ZStack{
Image("sfondo")
.resizable()
.frame(width: 350, height: 180)
CellBackground()
.offset(x: 93, y: 29)
HStack {
VStack(alignment: .leading) {
if isNataleOn == true {
Image("imageA").offset(x: 3, y: 15)
} else {
Image("none")
}
【问题讨论】: