How do I scale an image to fit the image representation in ios?

I put the image in an image view in xcode and set the mode to "scale to fit" but I find the image does not fit the image size. So how can I make the image fit the image size in ios?

Below is a screenshot of the storyboard.  Here is my screen shot.


source to share

2 answers

Several ways to play with:

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




To do this in your storyboard, select UIImageView

, open the Attributes inspector and choose Fill Aspect or Fit Aspect from the Mode drop-down menu.

UIImageView Content Mode



All Articles