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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to