Skip to content

Instantly share code, notes, and snippets.

@nenadvulic
Last active December 10, 2015 03:38
Show Gist options
  • Save nenadvulic/4375865 to your computer and use it in GitHub Desktop.
Save nenadvulic/4375865 to your computer and use it in GitHub Desktop.
Get correct UILabe height with NSAttributedString
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)activityLbl.attributedText);
CGSize targetSize = CGSizeMake(YOUR_WIDTH, CGFLOAT_MAX);
CGSize fitSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, [activityLbl.attributedText length]), NULL, targetSize, NULL);
CFRelease(framesetter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment