Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help about contentMode and autoresizingMask of UIImageView

i have picture like this image it will present on Landscape Mode

alt text

so if rotate device to Portrait, how to present image like this

alt text

like image 478
RAGOpoR Avatar asked Jun 03 '10 03:06

RAGOpoR


People also ask

How do I change aspect ratio in UIImageView?

If you are resizing UIImageView manually, set the content mode to UIViewContentModeScaleAspectFill . If you want to keep content mode UIViewContentModeScaleAspectFit do not resize imageview to 313. Image will adjust maximum possible width and height , keeping it's aspect ratio.

What is Contentmode in Swift?

A flag used to determine how a view lays out its content when its bounds change.


1 Answers

Use an UIImageView with these settings:

imageView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
                              UIViewAutoresizingFlexibleHeight);

imageView.contentMode = UIViewContentModeScaleAspectFit;
like image 143
MatterGoal Avatar answered Sep 18 '22 01:09

MatterGoal