使用到的UIViewContentMode
typedef NS_ENUM(NSInteger, UIViewContentMode) {
UIViewContentModeScaleToFill,
UIViewContentModeScaleAspectFit, // contents scaled to fit with fixed aspect. remainder is transparent
UIViewContentModeScaleAspectFill, // contents scaled to fill with fixed aspect. some portion of content may be clipped.
UIViewContentModeRedraw, // redraw on bounds change (calls -setNeedsDisplay)
UIViewContentModeCenter, // contents remain same size. positioned adjusted.
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
};
ScaleToFill:为将图片按照整个区域进行拉伸(会破坏图片的比例)
ScaleAspectFit:将图片等比例拉伸,可能不会填充满整个区域
ScaleAspectFill:将图片等比例拉伸,会填充整个区域,但是会有一部分过大而超出整个区域。
Top,Left,Right等就是将图片在view中的位置进行调整。
注:使用ScaleAspectFill后需要设置clip,
xib中需要在clip subview上打钩
本文详细介绍了UIViewContentMode的各种模式,包括ScaleToFill、ScaleAspectFit、ScaleAspectFill等,并解释了它们如何影响视图的内容显示。同时,文章还提到了如何通过设置clip来避免内容超出边界。
3707

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



