Re: Getting exact height of NSAttributedString
Re: Getting exact height of NSAttributedString
- Subject: Re: Getting exact height of NSAttributedString
- From: "Shawn Erickson" <email@hidden>
- Date: Fri, 21 Apr 2006 08:42:00 -0700
As an FYI using the following hack-ish code I can get size of the
drawn text including any text wrapping, etc. that may have taken place
based on attributes. Note I still haven't gotten -[NSAttributedString
boundingRectWithSize:options:] to work so that question is still
outstanding...
NSTextView* tmpView = [[NSTextView alloc] initWithFrame:[textField frame]];
[[tmpView textStorage] setAttributedString:[textField attributedStringValue]];
[tmpView setHorizontallyResizable:NO];
[tmpView sizeToFit];
NSLog(@"Before:%@, After:%@",
NSStringFromRect([textField frame]),
NSStringFromRect([tmpView frame]))
2006-04-21 08:32:22.428 XX[3060] Before:{{0, 11}, {317, 28}},
After:{{0, 11}, {317, 28}}
2006-04-21 08:32:27.312 XX[3060] Before:{{0, 11}, {317, 28}},
After:{{0, 11}, {317, 117}}
2006-04-21 08:32:52.458 XX[3060] Before:{{0, 11}, {317, 28}},
After:{{0, 11}, {317, 65}}
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden