[英]How to make UIImageView fit scaled image
I have a header view with a logo on the left which I want to be both left aligned and "Aspect Fit" scaled such that the image is as tall as possible in the available area. 我有一个标头视图,在该标头视图的左侧有一个徽标,我想同时将其左对齐和“纵横比匹配”,以使图像在可用区域中尽可能高。 If I set the mode to "Left" then it does left align but the small image does not scale up. 如果将模式设置为“左”,则它会左对齐,但小图像不会放大。 If I set the mode to "Aspect Fit" then it scales up perfectly, but it is centered in the imageview with padding on the sides. 如果将模式设置为“宽高比”,则它会完美缩放,但会在imageview中居中,并在侧面填充。 I have tried adding an inequality for the width in autolayout but it has no effect. 我尝试为自动布局中的宽度添加不等式,但是它没有任何效果。 If I increase the content hugging priority of the imageview, then the image is displayed at its smallest size with no scaling up. 如果增加内容包含imageview的优先级,那么图像将以最小尺寸显示,并且不会放大。
How can I have the image scaled up and also remove the padding around the image? 如何放大图像并去除图像周围的填充物?
将模式设置为“宽高比填充”,然后重试。
将模式设置为Aspect Fill
然后将UIImageView
调整为图像大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.