I'm following a basic swift guide but I'm struggling to understand this block of code:
struct CircleImage: View {
var body: some View {
Image("turtlerock")
.clipShape(Circle())
.overlay {
Circle().stroke(.gray, lineWidth: 4)
}
}
}
specifically, what kind of swift concept/data structure is used in .overlay {}
and var body: some View {}
I've searched through the swift documentation and couldn't find related concepts.
CodePudding user response:
.overlay { ... }
is a call of a methodoverlay
with a closure argument, using trailing closure syntaxsome View
is an opaque result type- SwiftUI view bodies use result builders, in particular ViewBuilder.