Setting a Button’s Title
A button can have two titles associated with it: normal and alternate. If the button type is
NSOnOffButton, only the normal title is ever displayed. If the button type is
NSToggleButton, the normal title is displayed when the button’s state is off (
NSOffState )and the alternate title is displayed when the button’s state is on or mixed (
NSMixedState). If you want a button to display different titles for all three states, you must subclass
If you want the title to contain plain text, use
setTitle: to set the normal title and
setAlternateTitle: to set the alternate title. If you want the title to contain styled text (for example, italics or bold), use
To set how the title is positioned relative to the button’s image, use
setImagePosition:, described in Setting a Button’s Image. If there is no image, the title is centered horizontally and vertically within the button. If the title is above, below, or overlapping the image, the title is centered horizontally within the button. To hide the title, use
setImagePosition: with an argument of
To set the title’s font, send
setFont: to the button’s button cell.
If you want a button to display its title in a tag when the mouse is over it, you need to use Tool Tips.