• 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
Re: Sizing text in a box
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sizing text in a box


  • Subject: Re: Sizing text in a box
  • From: email@hidden
  • Date: Tue, 5 Feb 2002 17:09:01 -0800

I'm using -[NSAttributedString drawInRect:] to draw a string in a rect (surprisingly enough :->). I'd like to have the text aligned to the *bottom* of the rect, though, and I'm a bit flummoxed. There is no attribute or paragraph style I can find that achieves this.
So I think I have to make my rect be the right height, such that aligned to the top is the same thing as aligned to the bottom. However, I don't know how many lines my text will be when wrapped into the rect, and -[NSAttributedString size] doesn't take a rect -- it seems to assume an un-wrapped layout. I can't find a simple way to do this -- it looks like I have to bust out NSLayoutManager. Which I know how to do, but -- ugh! Is there really no way to find out the extent my text will draw to before I actually draw it?
I have a feeling I'm just missing the obvious, but I searched all the Cocoa headers for methods returning NSSize and didn't hit pay dirt...

No, you aren't missing anything. This is an omission; on the other hand, using NSLayoutManager will do this and much more, and furthermore will be more efficient if you are first sizing and then drawing.

Hi Doug. :-> The efficiency is a non-issue in this case, and I don't really need the "much more". Would it be useful for me to log a bug on this omission, or is it already on your radar? And is there sample code anywhere I can just copy and paste, to avoid reinventing the wheel?
Thanks!

Ben Haller
Stick Software
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Sizing text in a box (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: Sizing text in a box
  • Next by Date: Constructing an NSURL with specified parameters
  • Previous by thread: Re: Sizing text in a box
  • Next by thread: Re: Sizing text in a box
  • Index(es):
    • Date
    • Thread