• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Trouble finding bounding rect of NSAttributedString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Trouble finding bounding rect of NSAttributedString
      • From: Jens Alfke <email@hidden>
  • Prev by Date: NSTextView, Bindings, and Display Updates
  • Next by Date: Re: IBOutlets or property + binding
  • Previous by thread: NSTextView, Bindings, and Display Updates
  • Next by thread: Re: Trouble finding bounding rect of NSAttributedString
  • Index(es):
    • Date
    • Thread