In my code I need “height” var to be refreshed depending of the size of the view (carousel). I thought that it could be possible by using GeometryReader, but the size is not correct :((
@SwiftUI.State var height: CGFloat = .zero
(...)
@ViewBuilder
func carousel(_ renderModel: renderModel) -> some View {
GeometryReader { geometry in
VStack(alignment: .leading) {
AnotherView(
(...)
)
}
}
.padding(.top, 20)
.padding(.bottom, 10)
.background(GeometryReader { geometry in
Color.clear.onAppear {
height = geometry.size.height
}
})
}
.frame(height: height)
}