【发布时间】:2021-02-26 01:44:35
【问题描述】:
这是我的代码:
struct GameView : View {
@State
private var clicked1 : Bool = false
var body: some View {
HStack {
VStack {
Image("shape0")
.overlay(clicked1 ?
RoundedRectangle(cornerRadius:10)
.stroke(Color.yellow, lineWidth: 7) : pass()
)
.onTapGesure {
print("Image is clicked")
}
}
}
}
}
但是pass() 周围发生了一些错误。
当变量clicked1 为false 时,我什么都不想做。
我该如何解决?
【问题讨论】:
-
这能回答你的问题吗? If without else ternary operator
-
@SergedeGossondeVarennes 这不是 Java 问题。