Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text Color in NSButton?



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.

References: 
 >Re: Text Color in NSButton? (From: Sherm Pendley <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.