简体   繁体   中英

Aspect ratio in UIImageView

I got app which can add photo from camera or gallery. After adding each photo showes in UIImageView . But they show with bad aspect ratio. Photoes are extended on UIImageView's size.

How can i show photoes with their real aspect ration?

UPD and what about small pictures? if user will add really small picture, this picture will resize on all area of UIImageView . How show this pictures in real size?

Doing myImageView.contentMode = UIViewContentModeScaleAspectFit; is one option.

But it isn't enough because it changes the aspect ratio of the image, but it doesn't change the source image.

The only way to do that is to use the UIGraphicsImageContext as explained there: Resize UIImage with aspect ratio?

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