Mac Developer Library

Developer

AppKit Framework Reference NSImageView Class Reference

Options
Deployment Target:

On This Page
Language:

NSImageView

An NSImageView object displays image data 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


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.
  • image image Property

    The image displayed by the image view.

    Declaration

    Swift

    var image: NSImage?

    Objective-C

    @property(strong) NSImage *image

    Discussion

    Use this property to change the image being displayed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The style of frame that appears around the image.

    Declaration

    Swift

    var imageFrameStyle: NSImageFrameStyle

    Objective-C

    @property NSImageFrameStyle imageFrameStyle

    Discussion

    The default value of this property is NSImageFrameNone.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The alignment of the cell’s image inside the image view.

    Declaration

    Swift

    var imageAlignment: NSImageAlignment

    Objective-C

    @property NSImageAlignment imageAlignment

    Discussion

    The default value of this property is NSImageAlignCenter.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The scaling mode applied to make the cell’s image fit the frame of the image view.

    Declaration

    Swift

    var imageScaling: NSImageScaling

    Objective-C

    @property NSImageScaling imageScaling

    Discussion

    The default value of this property is NSImageScaleProportionallyDown.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • animates animates Property

    A Boolean value indicating whether the image view automatically plays animated images.

    Declaration

    Swift

    var animates: Bool

    Objective-C

    @property BOOL animates

    Discussion

    When the value of this property is YEStrue, the image view plays animated images automatically using the timing and looping characteristics stored in the image data. The default value of this property is YEStrue.

    Decoding an animated GIF file is the only way to create an animated NSImage object. If the image view has been assigned an image that was created from animated GIF data, setting this property to YEStrue enables automatic playback of the animation. If this property is set to NOfalse, only the first frame of an animated image is displayed.

    Loading an animated GIF file using an NSImage object produces an image that uses an NSBitmapImageRep object. The NSImageCurrentFrame, NSImageCurrentFrameDuration, and NSImageFrameCount properties of the bitmap image representation determine the timing and looping characteristics of the animation. For more information, see NSBitmapImageRep Class Reference.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • editable editable Property

    A Boolean value indicating whether the user can drag a new image into the image view.

    Declaration

    Swift

    var editable: Bool

    Objective-C

    @property(getter=isEditable) BOOL editable

    Discussion

    When the value of this property is YEStrue, the user can set the displayed image by dragging an image onto the image view. The default value of this property is NOfalse, which causes the image view to display only the programmatically set image.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • A Boolean value indicating whether the image view lets the user cut, copy, and paste the image contents.

    Declaration

    Swift

    var allowsCutCopyPaste: Bool

    Objective-C

    @property BOOL allowsCutCopyPaste

    Discussion

    When the value of this property is YES, the user can cut, copy, or paste the image in the image view.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.