• 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: get the drawing text height
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get the drawing text height


  • Subject: Re: get the drawing text height
  • From: James Walker <email@hidden>
  • Date: Mon, 26 Jan 2009 11:59:40 -0800

David Alter wrote:
I'm drawing a string to screen and I want to get the height if I specify a
specific width. I'm drawing the string by using the NSString drawInRect:
withAttributes:. I do not see how I can get the height after the text has
wrapped. I have looked at  NSString sizeWithAttributes, but there does not
appear to be away to set the width so I can compute the height the text will
take up.
Any ideas?

Try this:

NSRect	mySize = NSMakeSize( myWidth, 0.0 );
NSRect bounds = [myString boundingRectWithSize: mySize
	options: NSStringDrawingUsesLineFragmentOrigin
	attributes: myAtts];
float	theHeight = NSHeight( bounds );

(Typed into e-mail)
--
  James W. Walker, Innoventive Software LLC
  <http://www.frameforge3d.com/>
_______________________________________________

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


References: 
 >get the drawing text height (From: David Alter <email@hidden>)

  • Prev by Date: Re: Safari-like tabs in my own app?
  • Next by Date: Re: Adding rows in NSPredicateEditor
  • Previous by thread: Re: get the drawing text height
  • Next by thread: Safari-like tabs in my own app?
  • Index(es):
    • Date
    • Thread