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
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.
UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With