Mac OS AppKit文档翻译——NSImageView
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.
NSImageView对象可以将NSImage对象的图片数据显示在一个矩形里。一个可以编辑的NSImageView的对象的使用方法和NSImage对象一样,支持复制、粘贴、拖拽、删除等操作。还有一点,必须是在可编辑的、有图片内容的状态下,NSImageView对象才能执行这些操作。
var image: NSImage?
The image displayed by the image view.
image——通过NSImageView类加载图片
var imageFrameStyle: NSImageFrameStyle
The style of frame that appears around the image.
imageFrameStyle——定义图片边框的显示样式
var imageAlignment: NSImageAlignment
The alignment of the cell‘s image inside the image view.
imageAlignment——定义NSImageView类里图片的对齐方式
var imageScaling: NSImageScaling
The scaling mode applied to make the cell’s image fit the frame of the image view.
imageScaling——定义NSImageView类里图片的拉伸模式,调整图片的大小
var animates: Bool
A Boolean value indicating whether the image view automatically plays animated images.
animates——布尔值类型,表示NSImageView类显示图片时是否带动画效果
var isEditable: Bool
A Boolean value indicating whether the user can drag a new
image into the image view.
isEditable——布尔值类型,表示用户能否直接将图片拖到一个NSImageView类里
var allowsCutCopyPaste: Bool
A Boolean value indicating whether the image view lets the user cut copy and paste the image contents.
allowsCutCopyPaste——布尔值类型,表示用户能否对图片内容进行剪切、复制、粘贴行操作
func init(image: NSImage)
init——实例化一个NSImageView类,带一个NSImage类参数