简体   繁体   中英

How to scale the image to fit the image view in ios?

I put an image in an image view in xcode and set "scale to fit" mode, but I find that the image doesn't fit the size of the image view. So how can I make the image to fit the size of the image view in ios?

Below is the screenshot of storyboard. 这是我的屏幕截图。

To do this in your storyboard, select your UIImageView , open the Attributes Inspector, and select either "Aspect Fill" or "Aspect Fit" from the "Mode" drop down menu.

UIImageView内容模式

A couple of methods to play with:

imageView.contentMode = UIViewContentMode.ScaleAspectFill
imageView.contentMode = UIViewContentMode.ScaleAspectFit

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