类似于 Label 的 文字居中类型,在展示图片时,也有一个ContentMode 属性 控制 图片展示的居中等样式.
contentMode 是 UIview 的一个属性
官网描述
The content mode specifies how the cached bitmap of the view’s layer is adjusted when the view’s bounds change. This property is often used to implement resizable controls. Instead of redrawing the contents of the view every time, you can use this property to specify that you want to scale the contents (either with or without distortion) or pin them to a particular spot on the view.
这里就不翻译了,
上官网地址
contentMode是什么
https://developer.apple.com/reference/uikit/uiview/1622619-contentmodecontentMode的值
https://developer.apple.com/reference/uikit/uiviewcontentmode
那么各个取值的效果如何呢
同样 上图,来自于官网
上地址
本文详细介绍了UIView的contentMode属性,解释了它如何调整视图层的缓存位图以适应视图边界的变化,这对于实现可缩放的控件特别有用。通过不同的contentMode设置,可以实现图片的缩放、拉伸或固定到视图特定位置。
723

被折叠的 条评论
为什么被折叠?



