NSImageView Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.0 and later.
Declared in
NSImageView.h
Related sample code

Overview

An NSImageView object displays a single image from an NSImage object in a frame. An editable image view object behaves as an image well and supports copying, pasting, dragging, and using the Delete key to clear its content. Note that an image view performs its action only when it’s editable and a user drags an image to it. To allow users to perform a custom action when they click an image, use a button.

Tasks

Choosing the Image

Choosing the Frame

Aligning and Scaling the Image

Responding to User Events

Animating Image Playback

Pasteboard Support

Instance Methods

allowsCutCopyPaste

Returns a Boolean value indicating whether the receiver allows the user to cut, copy and paste of the image contents.

- (BOOL)allowsCutCopyPaste
Return Value

YES if the user can cut, copy, and paste the image contents; otherwise, NO.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSImageView.h

animates

Returns a Boolean value indicating whether the receiver automatically plays animated images.

- (BOOL)animates
Return Value

YES if the receiver automatically plays animated images; otherwise, NO. The default value is YES for NSImageView objects you create programmatically. For NSImageView objects loaded from a nib file, the control takes the value set in Interface Builder.

Discussion

The timing and looping characteristics of the animation are taken from the image data. If this method returns NO, the receiver displays the first frame of the animation only.

Availability
  • Available in OS X v10.3 and later.
Declared In
NSImageView.h

image

Returns the NSImage object displayed by the receiver.

- (NSImage *)image
Return Value

The NSImage object.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSImageView.h

imageAlignment

Returns the position of the cell’s image in the frame.

- (NSImageAlignment)imageAlignment
Return Value

The image alignment. For a list of possible alignments, see setImageAlignment:. The default value is NSImageAlignCenter.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSImageView.h

imageFrameStyle

Returns the style of frame that appears around the image.

- (NSImageFrameStyle)imageFrameStyle
Return Value

The current image style. For a list of frame styles, see setImageFrameStyle:. The default value is NSImageFrameNone.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSImageView.h

imageScaling

Returns the way the cell’s image alters to fit the frame.

- (NSImageScaling)imageScaling
Return Value

The scaling behavior. For a list of possible values, see NSImageScaling. The default value is NSImageScaleProportionallyDown.

Availability
  • Available in OS X v10.0 and later.
Related Sample Code
Declared In
NSImageView.h

isEditable

Returns a Boolean value indicating whether the user can drag a new image to the frame.

- (BOOL)isEditable
Return Value

YES if the user can drag an image to the receiver's frame; otherwise, NO. The default value is NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSImageView.h

setAllowsCutCopyPaste:

Sets whether the receiver allows the user to cut, copy and paste the image contents.

- (void)setAllowsCutCopyPaste:(BOOL)allow
Parameters
allow

YES if the user can cut, copy, and paste the image contents; otherwise, NO to prevent the use of pasteboard operations.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSImageView.h

setAnimates:

Sets whether the receiver automatically plays an animated image that is assigned to it.

- (void)setAnimates:(BOOL)flag
Parameters
flag

YES if the receiver should automatically plays animated images; otherwise, NO.

Discussion

The timing and looping characteristics of the animation are taken from the image data. If you specify NO, the receiver displays the first frame of the animation only.

Availability
  • Available in OS X v10.3 and later.
See Also
Declared In
NSImageView.h

setEditable:

Sets whether the user can drag a new image to the frame.

- (void)setEditable:(BOOL)flag
Parameters
flag

YES if the user can drag an image to the receiver's frame; otherwise, NO. An editable image view behaves as an image well.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSImageView.h

setImage:

Sets the image of the receiver.

- (void)setImage:(NSImage *)image
Parameters
image

The image to display in the receiver.

Availability
  • Available in OS X v10.0 and later.
See Also
Declared In
NSImageView.h

setImageAlignment:

Sets the position of the image in the frame.

- (void)setImageAlignment:(NSImageAlignment)alignment
Availability
  • Available in OS X v10.0 and later.
Declared In
NSImageView.h

setImageFrameStyle:

Sets the kind of frame that borders the image.

- (void)setImageFrameStyle:(NSImageFrameStyle)frameStyle
Parameters
frameStyle

The possible values for this parameter are as follows:

Availability
  • Available in OS X v10.0 and later.
Declared In
NSImageView.h

setImageScaling:

Sets the way the image alters to fit the frame.

- (void)setImageScaling:(NSImageScaling)scaling
Parameters
scaling

The scaling option. For a list of possible values, see NSImageScaling.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSImageView.h