【发布时间】:2020-02-23 12:36:02
【问题描述】:
在下面的代码中,我知道
-
body是一个计算属性,它只有一个get部分。 -
return被省略VStack
但是 Vstack 之后的 { .. } 是什么?这是初始化还是闭包?
以及 {} 里面的内容,我认为没有任何回报。
struct ContentView: View {
var body: some View {
VStack {
MapView()
.frame(height: 300)
CircleImage()
.offset(y: -130)
.padding(.bottom, -130)
VStack(alignment: .leading) {
Text("Turtle Rock")
.font(.title)
HStack(alignment: .top) {
Text("Joshua Tree National Park")
.font(.subheadline)
Spacer()
Text("California")
.font(.subheadline)
}
}
.padding()
Spacer()
}
}
}
【问题讨论】:
-
return计算属性的关键字现在可以在 swift 5.1 中省略