• 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: How do you get the font used in a menu item?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do you get the font used in a menu item?


  • Subject: Re: How do you get the font used in a menu item?
  • From: Graham Cox <email@hidden>
  • Date: Wed, 22 Apr 2009 13:19:21 +1000


On 22/04/2009, at 1:10 PM, Jerry Krinock wrote:

I need to calculate how wide it will be when drawn with whatever font it is going to be drawn with.

***

But anyhow, I followed your advice. Since I need to setTitle: on my menu items anyhow, I created an attributed string and setAttributedTitle: instead. So, obviously now I know what the font is.

Wouldn't it be simpler to just measure the string itself? i.e. [NSAttributedString size]; ? Anytime you are having to delve into the font to do that sort of things usually indicates you're missing a trick ;-)


Problem solved. Odd that there is no getter for fonts in menus.

Hmmm, well I suppose it's in the spirit of not relying on arbitrary appearances of user interface elements to drive your code. I'd call that good (or at least reasonable) practice.


--Graham


_______________________________________________

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: 
 >How do you get the font used in a menu item? (From: Jerry Krinock <email@hidden>)
 >Re: How do you get the font used in a menu item? (From: Graham Cox <email@hidden>)
 >Re: How do you get the font used in a menu item? (From: Graham Cox <email@hidden>)
 >Re: How do you get the font used in a menu item? (From: Jerry Krinock <email@hidden>)
 >Re: How do you get the font used in a menu item? (From: Graham Cox <email@hidden>)
 >Re: How do you get the font used in a menu item? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: How do you get the font used in a menu item?
  • Next by Date: Re: Instance variable access from functions
  • Previous by thread: Re: How do you get the font used in a menu item?
  • Next by thread: newbie questions on NSString* as a class attribute
  • Index(es):
    • Date
    • Thread