Это можно сделать с помощью GeometryReader
, но не в этом месте, здесь это
ScrollView([Axis.Set.horizontal, Axis.Set.vertical]) {
VStack{
ForEach(self.model.hunks){ hunk in
HunkView(hunk: hunk)
}
}.background(GeometryReader { gr in
self.model.contentSize = gr.size // might be needed wrap in async
return Rectangle().fill(Color.clear)
})
}
Примечание: обратите внимание на комментарий в коде, cause now it is not clear how you're going to use that size, but if you'll right ahead from there change layout of views then it will be needed to wrap in
DispatchQueue.main .asyn c {} `, чтобы избежать цикличности обновления представления.