1

I am making an application which I would like to use the same image for multiple dimensions without stretching or cropping the image.

Can I make different images each supporting a dimension?

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

1

You can use contentMode as UIViewContentModeScaleAspectFit of UIImageView's Property.

It will be fit to your imageView, and will not be stretching or cropping. It will mainain aspect ratio of image. i.e

imgDevider.contentMode = UIViewContentModeScaleAspectFit;
Jatin Chauhan
  • 1,107
  • 1
  • 8
  • 21
  • 1
    **Thanks so much!** and again sorry i do not have enough reputation to like. –  Mar 29 '16 at 12:11
0

If you want to prevent stretching, you would have to create a different image for all supported iOS dimensions. Then, using your code, choose the correct image source according to the device's dimension.

Read here about getting the device dimensions.

Read here about changing the image source.

Community
  • 1
  • 1
Koby Douek
  • 16,156
  • 19
  • 74
  • 103