Closed sgil closed 3 years ago
I'm not sure what you're trying to achieve. Shouldn't intrinsicContentSize
give you the correct size of the label?
I'm looking to have a fixed width of 200, with a variable height determined by the amount of text in the label. If I use intrinsicContentSize, it gives me a the size of the bounding box of the label if the text were all in one line.
You should be able to set preferredMaxLayoutWidth
to 200. Does that work for you?
Yes it does! Thank you so much, closing this issue out
There is no way of generating a bounding box for the text given a fixed width, similar to
NSAttributedString.boundingRect(with:options:context:)
If you use
NSAttributedString.boundingRect(with:options:context:)
, estimate is wrong and text ends up getting cut off.