Search code examples
iosxcodeswiftimagedimension

Different images for different dimensions on iOS


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?


Solution

  • 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.