Guest User

Untitled

a guest
Jul 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. - (NSSize)sizeWithSize:(NSSize)size {
  2. if([self length] < 1) return NSZeroSize;
  3.  
  4. NSTextContainer *textContainer = [[[NSTextContainer alloc] initWithContainerSize:size] autorelease];
  5. NSTextStorage *textStorage = [[[NSTextStorage alloc] initWithAttributedString:self] autorelease];
  6. NSLayoutManager *layoutManager = [[[NSLayoutManager alloc] init] autorelease];
  7. [layoutManager addTextContainer:textContainer];
  8. [textStorage addLayoutManager:layoutManager];
  9. [layoutManager setHyphenationFactor:0.0];
  10.  
  11. // NSLayoutManager is lazy so for it to layout
  12. (void) [layoutManager glyphRangeForTextContainer:textContainer];
  13.  
  14. return [layoutManager usedRectForTextContainer:textContainer].size;
  15. }
Add Comment
Please, Sign In to add comment