tore
tore

Reputation: 689

How do I get dynamic height of view? (Xcode)

The static height of my view is set to 30, but it's text content vary in length, expanding the height of the view accordingly. I have tried to get a hold of the height programatically using

ingredientViewOutlet.frame.height

But this only returns the static height of 30. How do I get ahold of the dynamic height of the view?

Upvotes: 1

Views: 657

Answers (1)

DaWiseguy
DaWiseguy

Reputation: 1016

Inside:

    func viewDidAppear(_ animated: Bool){}

Add this:

    let height = ingredientViewOutlet.frame.height

This should let you get the 'dynamic' height of the view AFTER the view has already been loaded and adjusted to the screen.

Upvotes: 1

Related Questions