Trouble finding bounding rect of NSAttributedString
Trouble finding bounding rect of NSAttributedString
- Subject: Trouble finding bounding rect of NSAttributedString
- From: Dave DeLong <email@hidden>
- Date: Thu, 19 Nov 2009 14:28:11 -0700
Hi everyone,
I've been struggling for several hours to get the bounding rectangle of an NSAttributedString when drawn at a particular width.
I have an NSTextView that I need to resize dynamically. NSTextView appears to resize itself as I add text, but I also need it to shrink itself as I delete text. Here's what I've tried:
[myAttributedString size]
[myAttributedString boundingRectWithSize:NSMakeSize(desiredWidth, FLT_MAX) options:NSStringDrawingUsesDeviceMetrics];
[[myTextView layoutManager] usedRectForTextContainer:[myTextView textContainer]]
[[myTextView layoutManager] boundingRectForGlyphRange:NSMakeRange(0, [myAttributedString length]) inTextContainer:[myTextView textContainer]]
... and a few others
I've been over the documentation for NSAttributedString, NSLayoutManager, and NSTextContainer, and I've tried just about everything that looks like it might give me what I'm looking for. However, I've obviously missed something pretty fundamental to getting my string's rect. Any pointers?
Thanks!
Dave DeLong
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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