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

No way of getting bounding box for text #53

Closed
sgil opened this issue Jun 1, 2021 · 4 comments
Closed

No way of getting bounding box for text #53

sgil opened this issue Jun 1, 2021 · 4 comments

Comments

@sgil
Copy link

sgil commented Jun 1, 2021

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.

@tobihagemann
Copy link
Owner

I'm not sure what you're trying to achieve. Shouldn't intrinsicContentSize give you the correct size of the label?

@sgil
Copy link
Author

sgil commented Jun 23, 2021

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.

@tobihagemann
Copy link
Owner

You should be able to set preferredMaxLayoutWidth to 200. Does that work for you?

@sgil
Copy link
Author

sgil commented Jun 23, 2021

Yes it does! Thank you so much, closing this issue out

@sgil sgil closed this as completed Jun 23, 2021
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