Mac Developer Library

Developer

AppKit Framework Reference NSImageView Class Reference

Options
Deployment Target:

On This Page
Language:

NSImageView

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.

Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.0 and later.
  • Returns the NSImage object displayed by the receiver.

    Declaration

    Swift

    var image: NSImage?

    Objective-C

    @property(strong) NSImage *image

    Return Value

    The NSImage object.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – setImage:

  • Sets the image of the receiver.

    Declaration

    Swift

    var image: NSImage?

    Objective-C

    @property(strong) NSImage *image

    Parameters

    image

    The image to display in the receiver.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – image

  • Returns the style of frame that appears around the image.

    Declaration

    Swift

    var imageFrameStyle: NSImageFrameStyle

    Objective-C

    @property NSImageFrameStyle imageFrameStyle

    Return Value

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

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the kind of frame that borders the image.

    Declaration

    Swift

    var imageFrameStyle: NSImageFrameStyle

    Objective-C

    @property NSImageFrameStyle imageFrameStyle

    Parameters

    frameStyle

    The possible values for this parameter are as follows:

    • NSImageFrameNone—an invisible frame

    • NSImageFramePhoto—a thin black outline and a drop shadow

    • NSImageFrameGrayBezel—a gray, concave bezel that makes the image look like it’s below the surface of the surrounding view

    • NSImageFrameGroove—a thin groove that looks etched around the image

    • NSImageFrameButton—a convex bezel that makes the image stand out in relief

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var imageAlignment: NSImageAlignment

    Objective-C

    @property NSImageAlignment imageAlignment

    Return Value

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

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the position of the image in the frame.

    Declaration

    Swift

    var imageAlignment: NSImageAlignment

    Objective-C

    @property NSImageAlignment imageAlignment

    Parameters

    alignment

    The possible values for this parameter are:

    • NSImageAlignLeft

    • NSImageAlignRight

    • NSImageAlignCenter

    • NSImageAlignTop

    • NSImageAlignBottom

    • NSImageAlignTopLeft

    • NSImageAlignTopRight

    • NSImageAlignBottomLeft

    • NSImageAlignBottomRight

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var imageScaling: NSImageScaling

    Objective-C

    @property NSImageScaling imageScaling

    Return Value

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

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the way the image alters to fit the frame.

    Declaration

    Swift

    var imageScaling: NSImageScaling

    Objective-C

    @property NSImageScaling imageScaling

    Parameters

    scaling

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

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • isEditable isEditable Available in OS X v10.0 through OS X v10.9

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

    Declaration

    Objective-C

    - (BOOL)isEditable

    Return Value

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

    Import Statement

    Availability

    Available in OS X v10.0 through OS X v10.9.

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

    Declaration

    Swift

    var editable: Bool

    Objective-C

    @property(getter=isEditable) BOOL editable

    Parameters

    flag

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

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – isEditable

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

    Declaration

    Swift

    var animates: Bool

    Objective-C

    @property BOOL animates

    Return Value

    YEStrue if the receiver automatically plays animated images; otherwise, NOfalse. The default value is YEStrue 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 NOfalse, the receiver displays the first frame of the animation only.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

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

    Declaration

    Swift

    var animates: Bool

    Objective-C

    @property BOOL animates

    Parameters

    flag

    YEStrue if the receiver should automatically plays animated images; otherwise, NOfalse.

    Discussion

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

    For additional information on this topic, see the discussion for animates.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

    See Also

    – animates

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

    Declaration

    Swift

    var allowsCutCopyPaste: Bool

    Objective-C

    @property BOOL allowsCutCopyPaste

    Parameters

    allow

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

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.4 and later.

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

    Declaration

    Swift

    var allowsCutCopyPaste: Bool

    Objective-C

    @property BOOL allowsCutCopyPaste

    Return Value

    YEStrue if the user can cut, copy, and paste the image contents; otherwise, NOfalse.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.4 and later.