• 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: Space Required By Text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Space Required By Text


  • Subject: Re: Space Required By Text
  • From: <email@hidden>
  • Date: Wed, 30 May 2001 11:41:12 -0600 (MDT)

On Wed, 30 May 2001, David Remahl wrote:

> I have a text, which I would like to display in a text field. I would
> like to size the text field on run time to fit exactly the text. The
> text is line-broken by hard breaks, and occupies many lines, and
> approximately 80 columns. I would like to know the rect in which the
> text exactly fits using my font attributes.

Look into -sizeWithAttributes in NSString Additions!

Off the top of my head, something like:

int textWidth;

textWidth = [@"your string" sizeWithAttributes:yourDict].width;

would suffice!


References: 
 >Space Required By Text (From: David Remahl <email@hidden>)

  • Prev by Date: Re: Key events in NSTextField - Nevermind
  • Next by Date: Re: Space Required By Text
  • Previous by thread: Space Required By Text
  • Next by thread: Re: Space Required By Text
  • Index(es):
    • Date
    • Thread