Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Setting a Button’s Image

A button can have two images associated with it: normal and alternate. If the button type is NSMomentaryPushInButton, NSPushOnPushOffButton, NSMomentaryLightButton, or NSOnOffButton, only the normal image is ever displayed. If the button type is NSMomentaryChangeButton or NSToggleButton, the normal image is displayed when the button’s state is off (NSOffState) and the alternate image is displayed when the button’s state is on or mixed (NSOnState. or NSMixedState). If you want a button to display different image for all three states, you must subclass NSButton. (Although switch and radio buttons can display different images for all three states, there is no public interface for this feature.)

To set the normal image, use setImage:. To set the alternate image, use setAlternateImage:.

Note: If a button is a checkbox or a radio button, do not change its images. The images for these buttons are system-defined and changing them could lead to unpredictable results. If you want a switch or radio button with a customized appearance, either customize a toggle button (a button whose type is NSToggleButton) or subclass NSButton.

To set the position for a button’s image, use setImagePosition:, with one of the following values below. The default is NSNoImage

NSNoImageNSNoImage

NSImageOnlyNSImageOnly

NSImageOverlapsNSImageOverlaps

NSImageLeftNSImageLeft

NSImageRightNSImageRight

NSImageBelowNSImageBelow

NSImageAboveNSImageAbove



< Previous PageNext Page > Hide TOC


Last updated: 2007-12-11




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice