0

I am currently developing an app and I wish it to be used in multiple size classes.

enter image description here

As you can see from the image attached, my trophy image does not resize itself at all.

I have included 3 different sizes of the image in the assets folder and set the image into "Aspect fill" but it does not seems to work.

Update: I have set the the constraints for my image to both top and bottom container but it results the same.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • This tutorial may help you with using size classes with an image: http://www.raywenderlich.com/113768/adaptive-layout-tutorial-in-ios-9-getting-started – totiDev Jan 14 '16 at 14:40

3 Answers3

2

Read this: https://stackoverflow.com/a/26085718/3051458

Add the images in xcAssets folder as per above explanation.

You no need to give the extension of image (.png,.jpg etc.) It will pick the image as per the apple device.

Sample code:

UIImage *tropy = [UIImage imageNamed:@"tropy"];
UIImageView *tropyImageView = [[UIImageView alloc] initWithImage:tropy];

For more clear understanding read below totorial.

http://guides.codepath.com/ios/Adding-Image-Assets#step-3-using-the-image-set

Community
  • 1
  • 1
Ramesh_T
  • 1,251
  • 8
  • 19
1

If you are using autolayout, you can set aspect ratio constraints for width and height of the imageView to the cell content view, that way, if the cell grows image will grow too.

Ziare
  • 11
  • 3
0

You can resize the imageView and set height/width for different size classes. If you want to use different images for same image view across different size classes, i think it'll not be possible. checkout this tutorial: http://www.raywenderlich.com/113768/adaptive-layout-tutorial-in-ios-9-getting-started

Fayza Nawaz
  • 2,256
  • 3
  • 26
  • 61