I am trying to get the height of an item im creating by setting a geometry reader, then adding an .opAppear on an empty ZStack which pulls the height of the geo reader.
struct MyView: View {
@State private var height: CGFloat = 0
var body: some View {
GeometryReader { geometry in
ZStack {/*empty ZStack*/}.onAppear {perform: self.height = geometry.size.height
}
//More code...
}
}
}
My first question is why do I get an error which says "cannot convert value type '()' to expected argument type '(() -> Void)?'" on the .onAppear
My second question would be is if there is a better item than a ZStack to use for this?