Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to provide different images for UIImageView on different size classes

I am developing an universal application with iOS8 size classes. I have a imageview which has to show different images on iPad and iPhone, I don't want to use two imageviews and install each on different size classes or change the image programmatically because I think there should be an easier way.

Thanks in advance Kind Regards Ali

like image 748
AliAx Avatar asked Nov 02 '14 12:11

AliAx


People also ask

How do I change the size of my UIImageView?

The simplest way is to set the frame of your UIImageView and set the contentMode to one of the resizing options. I would NOT retain the result here. newImage will be autoreleased already, and it should up to the method that called this to retain it or not.

What is the difference between a UIImage and a UIImageView?

UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .

How do I change aspect ratio in UIImageView?

To maintain aspect ratio I calculated the width of UIImageView = (320/460)*450 = 313.043 dynamically. And set the contentMode For UIImageView is UIViewContentModeScaleAspectFit. And set the image(320x460) to image view but it is some what blur.


1 Answers

You can use assest catalog for separate iPhone and iPad images. Add an image to assets catalog and choose attributes inspector on the right side bar and choose the device specific in "Device" tap than you can add different images for iPhone and iPad.You can also add images for different size classes by using width and height in attributes inspector.

I hope this can be help for you.

like image 112
Le'Kirdok Avatar answered Oct 26 '22 14:10

Le'Kirdok