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的内容。


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 如时光染白鬓角,陈没的胸口避无可避地鲜血漫涌,但斗志高昂的他毫不在意,因为这对他来说,就如呼吸一般寻常。没有被疼痛...
    萧寒浅阅读 227评论 1 8
  • 朱门悲歌 楔子 故事是从什么时候开始的?他不知道,他只是个小小牢头。可他记得那晚是他过的最胆战心惊的一晚。那天,是...
    薛英葰阅读 196评论 0 1
  • 文/杨柳君 你的企业互联网+了吗? 各类信息渠道经常见到这样的提问,企业界朋友们交流时,也常有此类探讨。 什么是互...
    杨柳君阅读 183评论 0 1