Skip to content

Instantly share code, notes, and snippets.

@wess
Created July 24, 2012 15:31
Show Gist options
  • Save wess/3170684 to your computer and use it in GitHub Desktop.
Save wess/3170684 to your computer and use it in GitHub Desktop.
another CT size try
- (CGFloat)getContentHeight
{
CTFramesetterRef tmpFrameSetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)_body);
int textLength = [_body length];
CFRange range;
CGFloat maxWidth = self.width;
CGFloat maxHeight = CGFLOAT_MAX;
CGSize constraint = CGSizeMake(maxWidth, maxHeight);
CGSize contentSize = CTFramesetterSuggestFrameSizeWithConstraints(tmpFrameSetter, CFRangeMake(0, textLength), nil, constraint, &range);
return contentSize.height;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment