• 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: width of NSString in pixels
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: width of NSString in pixels


  • Subject: Re: width of NSString in pixels
  • From: Raphael Sebbe <email@hidden>
  • Date: Tue, 27 Nov 2001 15:04:39 +0100

Here is a code fragment that does what you want (I believe you should have a look at NSString additions in AppKit doc) :

NSString *drawString = [NSString stringWithFormat:@"Time: %g\nValue: %g", _spTime, _val];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSColor grayColor], NSForegroundColorAttributeName,nil]; // you can add the font... here
NSSize size = [drawString sizeWithAttributes:attributes];


Raphael

On Tuesday, November 27, 2001, at 01:27 PM, Robert Miller wrote:

Hello,

Can someone tell me how to determine the width of an NSString in
pixels using Cocoa? I can only find this functionality in the Carbon API
using the Appearance Mgr. ? Am I missing something ?

Thanks in advance,
Regards,
Bob M.
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


References: 
 >width of NSString in pixels (From: Robert Miller <email@hidden>)

  • Prev by Date: problem with scrollToPoint
  • Next by Date: Newbie Mac Programmer-wannabe question
  • Previous by thread: Re: width of NSString in pixels
  • Next by thread: Re: width of NSString in pixels
  • Index(es):
    • Date
    • Thread