0

I just want to use one set of image asserts for all iPhones and iPads(Universal), Is it possible to do the same? or what will be the best solution for the making a build lighter.

Haroon
  • 697
  • 1
  • 9
  • 24
  • Yes, its possible to use single image for development, you can opt for `@2x` image only, and use it as 1x images, the only problem you will face is while you will design as you will have to calculate the image size / 2 for all your components, in the end you need to rename `@2x` images to 1x remove `@2x` images, as devices will look for `@2x` image it won't be there, hence it will use only 1x images. Though this is not a good idea to do, best way to make your app lighter to design it that way where you can easily use solid colors and design you interface programmatically. – iphonic Nov 14 '14 at 05:47
  • Thanks iPhonic,Even i am thinking of the same solution for it, but I am looking for any solution which some what automatic and supported by apple as well. – Haroon Nov 14 '14 at 05:58

2 Answers2

0

YES, it is possible ti use one image asserts for all devices. just add new image set

in assert by Right click. And the add images for required devices in created Image set.

you can use Image set but it's name,and images are automatically loaded with different devices.

UPDATED

if you want to titlelogo.png for all device then make new image set in Images.xcassets and name it as AssetTitlelogo. and the add all images in it as in screenshot.img

You use image by

[UIImage imageNamed:@"AssetTitlelogo"]; /// use your asset Name

It's load right image for right Device..

Community
  • 1
  • 1
hmdeep
  • 2,910
  • 3
  • 14
  • 22
  • can you please explain me a bit more one this, like if I want to use 'titlelogo.png' for all screen resolutions and I don't want make different xibs or storyboard for iPad and iPhone. – Haroon Nov 14 '14 at 05:56
  • @hmdeep what you are saying is still require 3 images 1x, 2x and 3x. He wants to use only one image, how your solution solves his problem? – iphonic Nov 14 '14 at 07:07
0

Yes, if you use a retina image without the @2x or @3x in the name and your UIImageView is set to ScaleToFill it will automatically scale down your image on non-retina devices. it is easy to test with the simulators to see how the image will look at the different screen resolutions.

the trade off is non retina devices will suffer with more memory usage than is needed for them (and usually the non-retina devices are some what limited in memory already compared to the latest apple products) but if you arent dealing with a lot of images on the screen at once then this shouldnt have an adverse effect

Fonix
  • 11,447
  • 3
  • 45
  • 74
  • Thanks `Fonix` - I am actually looking for some class/framework that actually modify(reduce or enlarge) the image according to the device. seems like we don't have yet. – Haroon Nov 17 '14 at 13:04