Created
July 24, 2012 15:31
-
-
Save wess/3170684 to your computer and use it in GitHub Desktop.
another CT size try
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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