我尝试在点击手势开始和结束时添加动作,但它不起作用!并在示例代码下方。
@State private var opacity = 1.0
var body: some View {
Image(systemName: "plus.square.on.square")
.opacity(opacity)
.onTapGesture {
opacity = 0.2
}
.gesture(
TapGesture()
.onEnded({ _ in
opacity = 1.0
})
)
}