Ability to calculate the height of the view
alexjameslittle opened this issue · comments
Alex little commented
I am planning to use this view to display messages as markdown in a UICollectionView cell that hosts a SwiftUI view. How would I be able to pre-calculate the required height this view will be based on a string and a constrained width?
DasAuto commented
Hi Alex! 👋
I don't think it has the ability to pre-calculate the size itself, because of the fact of SwiftUI; however, using GeometryReader
to get the size is totally legit in the scenario.
For example:
struct ContentView: View {
var body: some View {
GeometryReader { geo in
Parma(markdown)
.onAppear {
print(geo.size.height)
}
}
}
}
Update the cell height when the view appears.