• 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: Text Color in NSButton?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text Color in NSButton?


  • Subject: Re: Text Color in NSButton?
  • From: Steve <email@hidden>
  • Date: Fri, 29 Nov 2002 09:38:46 +0000

Thanks:

NSMutableDictionary *attrs = [[NSMutableDictionary alloc]init];
NSFont *font = [NSFont fontWithName:@"Lucida Grande" size:10.0];
[attrs setObject:font forKey:NSFontAttributeName];
[attrs setObject:[NSColor redColor]forKey:NSForegroundColorAttributeName];
NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:originalString attributes:attrs];
[myButton setAttributedTitle:attrStr];

This works, but I couldn't find how to centralize the drawing position within the buttton.
Also, none of the attribute types listed in the documentation apply to bold/italic styles, and yet there is an NSUnderlineStyleAttributeName.

Steve


On Thursday, November 28, 2002, at 12:28 PM, Sherm Pendley wrote:

On Thursday, November 28, 2002, at 06:45 AM, Steve wrote:

How do I programmatically change the text color of the title of an NSButton?

Create an NSAttributedString with the properties you want (color, font, etc.), and assign it to the button with setAttributedTitle:.

sherm--

If you listen to a UNIX shell, can you hear the C?
_______________________________________________
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.
_______________________________________________
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.

  • Follow-Ups:
    • Re: Text Color in NSButton?
      • From: Fritz Anderson <email@hidden>
References: 
 >Re: Text Color in NSButton? (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: open file
  • Next by Date: Editing text inside a grid
  • Previous by thread: Re: Text Color in NSButton?
  • Next by thread: Re: Text Color in NSButton?
  • Index(es):
    • Date
    • Thread