[英]Image won't fit in scale to fill mode in image view
这是一个非常简单的任务,但是对我来说不起作用。 这是我所做的:
然后在我的模拟器中,视图控制器如下所示:
如屏幕截图所示,图像周围有空白。
我可以确认图像本身周围没有空格,并且图像视图很好地固定在其视图的四个侧面。 那么为什么会这样呢? 我有想念吗?
可能是您的图像从左到右一点透明,如果白色也会改变,则尝试更改veiw的颜色,然后它将确认。
将您的图像设置为
yourimage.contentMode = UIViewContentModeScaleAspectFit;
根据apple documentation
使用的其他一些变体
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,
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.