Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

McBgnr

macrumors regular
Original poster
Apr 13, 2009
144
0
Hello All,

I have just started working on Mac OS. I have a simple Cocoa Application, using Xcode, with a few controls in it. Now i want to set the front color and back color for these controls.

However, I could not any attributes in the Interface Builder, which could be set to change the default front color and back color of the controls.

Guys, please suggest some ways of doing this!

Cheers
McBgnr
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Font color can be changed by just using the standard color panel for a text field. With your text field selected, go to Tools > Attributes Inspector.

For buttons, look at setAttributedTitle:

For custom background colors on a button you will probably need to subclass NSButton and/or NSButtonCell and draw it yourself. Edit: or provide a custom NSImage.
 

McBgnr

macrumors regular
Original poster
Apr 13, 2009
144
0
Cool.... didn't know that it was so easy to set the text color for a TextField :). Thanks a bunch.

However, am not sure how to make use of the setAtrributedTitle field in case of buttons. I have added an Objective C class to my application and also added an object pointing to the Objective C class in the MainMenu.xib file thru Interface Builder. Please suggest what changes I will have to make in the implementation file go get this working for buttons?
 

McBgnr

macrumors regular
Original poster
Apr 13, 2009
144
0
I have not yet connected the button via IBOutlet to the Objective C class object. I am not sure how I can add the IBOutlet connection and how I can use it to set the title color.

Any suggestions will be helpful.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Well look at some tutorials or grab a book. This is Cocoa 101, and you should get yourself well familiarized with how this works.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.