Reputation:
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?
Upvotes: 1
Views: 119
Reputation: 1127
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;
Upvotes: 1
Reputation: 16675
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.
Upvotes: 0