UIImageView 中的纵横比 [英] Aspect ratio in UIImageView

查看:20
本文介绍了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?

这篇关于UIImageView 中的纵横比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆