is there any way to set text color of a (NS)Button in IB?

as the title reads.. is there? i'm using xcode 4.6

xcode-OTHER, OS X Mountain Lion (10.8.2)

Posted on Mar 7, 2013 6:30 PM

Reply
4 replies

Mar 8, 2013 8:34 AM in response to swesluggo

If you are asking about the actual text color then yes it is possible but not so simple.


If you look at the class definition for NSButton youwill see two methods


  • – setAttributedAlternateTitle:
  • – setAttributedTitle:


These will allow you to specify an attributed string as the button label and in the attributed string you can set the string attributes such as color.


If you are just looking to change the background color or somehtingalong those lines that can be done right in NSButton.

Mar 10, 2013 12:41 AM in response to Frank Caggiano

Hi Frank and thank you for your response!

I know how to do it programmatically but i was wondering if it is possible in Interface Builder..? Seeing as it is just an attributedString i would imagine it should be.. I've tried setting the color of it in the font editor of the button, the cell and then, thinking i had finally found it, of the actual string (by first selecting the cell, then double-clicking the title, right-clicking the directly editable text and selecting Font > Show colors) but without results. Right now i've subclassed NSButton and implemented some setTitleColorWith... functions but it feels a bit silly to have to set up the default UI-look programmatically when you have IB!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

is there any way to set text color of a (NS)Button in IB?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.