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

Set Box Size before set text #2

Closed
gastonmorixe opened this issue Aug 2, 2015 · 2 comments
Closed

Set Box Size before set text #2

gastonmorixe opened this issue Aug 2, 2015 · 2 comments

Comments

@gastonmorixe
Copy link

I am using auto-layout so I need to set the box size before or at same time the text is set. Size to fit is not working for me, I don't know why.

Because I am using NSAttributedText and oficial apple methods to get the proper size are not working always as expected, after researching I found this works great.

Feel free to consider adding this to get the proper text size at setText time.

CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)attributedString);
CGSize targetSize = CGSizeMake(320, CGFLOAT_MAX);
CGSize fitSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, [attributedString length]),NULL, targetSize, NULL);
CFRelease(framesetter);
@overboming
Copy link
Owner

I have changed ZCAnimatedLabel to support auto layout better

@gastonmorixe
Copy link
Author

great! thanks

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