iOS UIImageView的显示模式
作者:
Eyes_cc | 来源:发表于
2020-04-28 16:24 被阅读0次extension UIView {
public enum ContentMode : Int {
# 当图片大于imageView时
// 是contentMode的默认值,
// 拉伸充满整个imageView,如果imageView的宽高比和图片的宽高比不一致,则图片会被拉伸.宽高都会被拉伸。
case scaleToFill
// 比较常用
// 内容缩放显示完整的图片(不改变比例,图片最短边为参照,会与imageView重叠)。剩余部分是透明的
case scaleAspectFit // contents scaled to fit with fixed aspect. remainder is transparent
// 内容缩放显示完整的图片(不改变比例,图片最长边为参照,会与imageView重叠)。
case scaleAspectFill // contents scaled to fill with fixed aspect. some portion of content may be clipped.
# 当图片小于imageView时
// 是contentMode的默认值,
// 按照imageView的比例进行拉伸,不会与imageView重叠。如果imageView的宽高比和图片的宽高比不一致,图片会被拉伸
case scaleToFill
// 放置商品等图片时比较常用
// 按图片比例居中显示完整的图片,不会与imageView重叠。剩余部分是透明的
case scaleAspectFit // contents scaled to fit with fixed aspect. remainder is transparent
// 为了适配时,比较常用
// 按图片比例居中放大显示完整的图片,不会与imageView重叠。。剩余部分是透明的
case scaleAspectFill // contents scaled to fill with fixed aspect. some portion of content may be clipped.
case redraw // redraw on bounds change (calls -setNeedsDisplay)
case center // contents remain same size. positioned adjusted.
case top
case bottom
case left
case right
case topLeft
case topRight
case bottomLeft
case bottomRight
}
}
本文标题:iOS UIImageView的显示模式
本文链接:https://www.haomeiwen.com/subject/zcyuwhtx.html
网友评论