UIImage View的contentMode的属性理解

UIViewContentModeScaleToFill  //不是按照比例放大,把整个view撑满,失真,扭曲

UIViewContentModeScaleAspectFit //按照比例放大,保持图片原有的比例,不会扭曲,导致view会有些空白

UIViewContentModeScaleAspectFill // 按比例放大,同时撑满整个view,导致有一部分不会显示

UIViewContentModeRedraw // 重绘视图边界

UIViewContentModeTop, 视图顶部对齐

UIViewContentModeLeft, 视图左侧对齐

UIViewContentModeCenter,// contents remain same size. positioned adjusted.  视图保持等比缩放

参考文章:http://www.dreamingwish.com/article/coreanimation-programming-guide-e-the-content-layer.html

CALayer与 contentMode对应的属性叫做contentsGravity,但是它是一个NSString类型,而不是像对应的UIKit部分,那里面的值是枚举。contentsGravity可选的常量值有以下一些:

Scaling constant

Description

kCAGravityResize

Resize the content image to completely fill the layer bounds, potentially ignoring the natural aspect of the content. This is the default.

kCAGravityResizeAspect

Resize the content image to scale such that it is displayed as large as possible within the layer bounds, yet still retains its natural aspect.

kCAGravityResizeAspectFill

Resize the content image to scale such that it is displayed filling the layer bounds, yet retaining its natural aspect. This may cause the content to extend outside the layer bounds.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容