Re: NSTextField vertical sizeToFit
Re: NSTextField vertical sizeToFit
- Subject: Re: NSTextField vertical sizeToFit
- From: Rob Napier <email@hidden>
- Date: Thu, 17 Apr 2008 14:18:07 -0400
On Apr 13, 2008, at 4:38 AM, Jeff wrote:
Any way to take an NSTextField containing some amount of text, and
resize it
vertically so all the text fits within the frame? The sizeToFit
message
seems to do this, except on the horizontal axis.
Thank you!
It's a little easier to do this with an NSTextView:
NSRect frame = NSMakeRect(0, 0, someWidth, MAXFLOAT);
NSTextView *tv = [[NSTextView alloc] initWithFrame:frame];
[[tv textStorage] setAttributedString:someAttributedString];
[tv setHorizontallyResizable:NO];
[tv sizeToFit];
You can do a similar process with an NSTextField, but you have to set
the NSParagraphStyle to word wrap, and I find it easier to just
configure an NSTextView. If you need an NSTextField, I can walk
through that.
-Rob
--
Rob Napier -- Software and Security Consulting -- http://robnapier.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden