简体   繁体   中英

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. 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.

How can I have the image scaled up and also remove the padding around the image?

Here is my test layout: 图像布局

将模式设置为“宽高比填充”,然后重试。

将模式设置为Aspect Fill然后将UIImageView调整为图像大小。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM