Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to calculate the height of the view #1

Open
alexjameslittle opened this issue Sep 10, 2020 · 1 comment
Open

Ability to calculate the height of the view #1

alexjameslittle opened this issue Sep 10, 2020 · 1 comment

Comments

@alexjameslittle
Copy link

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?

@dasautoooo
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants