Mac OS AppKit文档翻译——layerContents(forContentsScale:)

layerContents(forContentsScale:)

Returns an object that may be used as the contents of a layer.

返回一个对象,这个对象将用作layer对象的内容。

Declaration——方法声明

func layerContents(forContentsScale layerContentsScale: CGFloat) -> Any

Parameters——参数

layerContentsScale

The scale factor for the resulting image. Obtain the value for this parameter by calling the recommendedLayerContentsScale(_:) method.

根据图片计算得出的比率。通过调用recommendedLayerContentsScale(_:)方法获得值。

Return Value——返回值

A object that you can assign to the contents property of a CALayer object. This object contains the image data from the current image optimized for the specified scale factor.

返回值——可以将这个返回值赋值给CALayer对象的内容属性。这个返回值包含给当前图片按特定的比率优化后的图片数据。

Discussion——讨论

Use this method in situations where you want to use the image as the contents of a layer. This method provides the image data wrapped in an object that correctly respects all of the possible content gravities supported by the layer. Use of the returned object as the layer’s contents is recommended over the use of the NSImage object itself.

使用这个方法的情况:当需要使用图片作为layer的内容。这个方法提供的图片数据绑定在一个表示layer支持的所有可能的content gravities对象上。对比使用NSImage对象本身,更推荐使用返回值作为layer的内容。


你可能感兴趣的:(Mac OS AppKit文档翻译——layerContents(forContentsScale:))