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?
To maintain aspect ratio I calculated the width of UIImageView = (320/460)*450 = 313.043 dynamically. And set the contentMode For UIImageView is UIViewContentModeScaleAspectFit.
2:3 Aspect Ratio. 2:3 is the most popular aspect ratio for printing. Print sizes that are a 2:3 aspect ratio and are popular with poster, canvas, and decal printing are 24 x 36 inches and 40 x 60 inches.
UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With