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.
网友评论