iPad image sizes - ios

I am creating an application for iPad, the images I have available from graphic designer are
really big, almost twice the size.
According to the graphic designer, the images were created keeping in mind iPad 3.
So if I reduce my image size to half and use them, is it going to make any difference on iPad3?
Or there is no difference and it will be compatible in both.
I am new to iOS development and not sure about the image resizing in detail.
Thanks in advance.

You will have two versions of every image where one is double the size of the other and the operating system will decide which version to use. You just need to name the images correctly.
Images for ipad3 will have #2x within the name. Example
image.png <--- non retina ipad
image#2x.png <------ retina ipad (ipad3)
Here is a post explaining this more: Preparing your iPhone App for Higher Resolutions

Related

Assets.xcassets - Universal not working

I am using Universal for Assets.xcassets in the hopes that I only have to create 3 different sizes for each image I use. But, despite Assets.xcassets telling me that my images are Universal in the Attributes Inspector, when I test on my iPad, the images are blurry and aren't as sharp as they are on my iPhone, making me question why there is a Universal option.
I've double checked all my images and they are all correctly sized.
My questions:
In the Attributes Inspector, under Universal, there are iPhone and iPad options. In order for my iPad to provide crystal clear images, should I use the iPad option?
And if I should: What's the point of the Universal option if it doesn't really do its job?
Also if I should: What size images do I use. The iPad option gives me the options of 1x and 2x size images. So, should the size of the 1x image for iPad be the same size as 1x image for Universal?
Thanks in advance.
Universal merely means that this app will run on iPad and iPhone natively. Thus the devices on which your app might run can have a single-resolution, double-resolution, or triple-resolution screen.
If you have checked Universal, accordingly, you should see three slots:
Your job, therefore, is to make three versions of your image, sized in proportion. If the 1x is 100x100, the 2x should be 200x200 and the 3x should be 300x300. The version in the appropriate slot will be used at runtime in accordance with the screen resolution of the device we're running on.
The asset catalog does not do any image sizing for you. You have to do it beforehand. (I find Graphic Converter a nice utility for this purpose.)
You could just supply a 3x image and allow the runtime to size down for you, but this is a waste of memory; Apple specifically advises against this in one of the WWDC 2016 videos. So just bite the bullet and make all three image sizes yourself.
Finally:
when I test on my iPad, the images are blurry and aren't as sharp as they are on my iPhone
Hmm, the only reason I can think of for this is that your app is not running natively on the iPad, but is an iPhone app running in "emulation mode" on the iPad. If that's the case, nothing you can do is going to make it look really good. It would be better to write your app as a true Universal app. That is a setting that you make when you create the project initially (though it can be changed later by editing the app target).

Adding iOS #1x, #2x, #3x PER device, how to?

I recently asked a question about why we use the 3 different image types listed above, and got good/detailed responses. It also lead me to question something else...
Assume I am working in XCode (with SWIFT) and have the three image sizes #1x, #2x, #3x for a particular say UIImage on an iPhone. Now, I want it to look nice on iPad, so I add some scaling. However, this will change the sizes of the 1x, 2x, 3x images I need for the iPad, so I need to make 3 more to compensate for that new size. Now how will XCode differentiate between the two? Do I need to check what size screen I am using and then choose the images?
I read that assets could help me, but that only deals with iPhone vs. iPad, what if I scale my images across iPhone 4, 5, 6 and iPad. That's a lot of different sizes and #x images, and I read Apple doesn't like device checking so I'm not sure how that would happen.
I hope this makes sense. I get the #1x, 2x, 3x per device, but if my app is being designed for universal device use, then how do I manage all of these different sizes in code for the proper device?
You really should use image asset catalog. It makes it almost too easy. Here is the definition Apple gives so you know it's not hearsay:
Image sets: Used for most types of images, an image set contains all the versions, or representations, of an image that are necessary to support various devices and scale factors.
And it goes on further:
Each set in an asset catalog has a name. You can use that name to programmatically load any individual image contained in the set. To load an image, call the platform specific class method, passing in the name of the set that contains the image. The OS will load the image from the set that is most appropriate for the current scale factor
So there really is not much for you to do. I don't know where you heard the opposite
See Documentation here
You need to check the size of the biggest image, if you are using an iPad figure out the size of the UIImageView frame. For instance if it is 400*400pts then your image will be 1200*1200. Just use a single image. I don't think you need to include the #2x and #1x. The 1200*1200 covers your bases for the largest possible image and scaling down will still have plenty of pixels left over for the full #3x resolution on other devices and so on. This is how I understand it anyway. I also wondered this myself and only found #1x #2x #3x useful for things that I didn't scale up as the screen size increased such as some buttons.

Do I need to include images for a non-retina iPhone and 6+?

In my app I am using images of size 155*155pts so I am supplying it with an image of 310*310px resolution. I know that I can use image.png image#2x.png and image#3x.png and then [UIImage imageNamed: image] to select the image appropriate for the resolution. My question is do I really need to include a lower resolution version of size 155*155px, won't the UIImageView it's displayed in just scale it appropriately? A similar question for the iphone6+, if I don't include the #3x version will it just use the #2x and display it as clearly as a standard retina screen would?
Even though there are plenty of answers at SO discussing this topic
(Google them) e.g. How to handle image scale on all the available iPhone resolutions?
Its just a recommendation to to use scaled up images with #2x and #3x in your app. You don't have to create them. From my experience in making apps, in almost all of them I have never used multiple images. I create one UIImage and use it for all the phone sizes. I then either use auto layout or manually adjust the width height of UIImages myself.
There is a reason I do that is lets say one of your sample1.png image is 1MB then you will need to create 3 of them.
sample1.png
sample1#2x.png
sample1#3x.png
You just doubled or tripled your binary size which is bad for downloads. There always be users running non-retina devices and it would be shame to not support them. Can you only make retina enabled apps, of course you can and Apple will approve those as they will be testing your apps on the latest devices but the best approach is to support all devices.
It depends, if you only support non-retina devices you donĀ“t have to add the normal image size anymore.
The scaling for the 6+ works with the #2x images but i guess you will see a quality difference

iPhone 6+ images

I have a question that I need confirmation on. I know that the Apple Developer document shows App icon size at #3x
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html.
Does this also apply to regular images that you use in your App? I just need to make 100 percent sure. The other stackoverflow answers I encountered just show App icon sizes, but doesn't address regular images that you use through out your App.
If you want your app to take full advantage of the Retina HD display then yes, you need to have all versions for all images used by your app, i.e. image.png, image#2x.png, image#3x.png.
Dont forget to setup launch screens for each iPhone size, or your bigger phones will just enlarge your app views without really using AutoLayout or using the high def images.
It doesn't apply for regular images that you use in you app. Make sure they are with good pixels.
Provide high-resolution (#2x) versions of all image assets.
Images that are not #2x will appear blurry on the Retina display.
source:
https://developer.apple.com/design/tips/

How important are non-retina images?

I'm releasing a new update for one of my apps and I was disappointed to see that it just barely surpasses 20MB estimated size (20MB is the point where it can no longer be downloaded over cell data).
My app contains a lot of images, so I could greatly reduce the size if I didn't have all those non-retina images. I know that there are some non-retina devices that will be running my app. So here are my questions:
How will a non-retina device react if I have an image with the #2x suffix but no non-retina image without it.
If I use a retina sized image without the #2x suffix and scale it down to the size I want to display it at programmatically and/or
through interface builder, will it still maintain full quality on
retina devices? Will the quality be worse on a non-retina device
than using an image I downscaled from the original using GIMP
instead?
How will a non-retina device react if I have an image with the #2x suffix but no non-retina i
image without it.
I use that approach on a couple of apps of mine and it works flawlessly. I am not able to detect any performance or visual issues on non-retina display devices (concretely, iPad 1/2 and mini).
I am not sure what can happen on older iOS version, since I only support iOS5+ on those apps.
If I use a retina sized image without the #2x suffix and scale it down to the size I want to display it at programmatically and/or through interface builder, will it still maintain full quality on retina devices? Will the quality be worse on a non-retina device than using an image I downscaled from the original using GIMP instead?
This comes down to how you set interpolation options while doing the scaling. See this other question for more details on how interpolation quality affects scaling down an image. In GIMP or Photoshop you also have control on the interpolation to be used for scaling, btw.
But in the end I don't think you need to go this way.
Most importantly, that bandwidth limit has been raised to 50MB.
OK.
If you only provide one image then you have one of two possibilities.
The image is a non-retina image. This will look fine on the non-retina. It will look identical on a retina device. But will look low quality next to a retina image.
The image is a retina image. On the retina device it will still load as a retina image. It will look fine. However, on the non-retina device it will have to scale down the image. This takes extra cycles of the CPU so could affect performance and it may not look how you want. It may shrink the image using a different method than you want and so may make the image look odd.
This is the same with or without a suffix.
The best solution is to create retina images and then use your editor of choice to create the standard versions. Nothing will stop you only providing one image but it may lead to a look and performance that you don't want.
On a side note. The size for downloading over cellular data was increased to 50MB.
Try these things using the simulator and find out for yourself.
I think the answer is that UIImage will ignore the #2x choice if you're relying on [UIImage imageNamed:#"without2xSuffix.png"] and not find anything, but I haven't tried it. Deliberately requesting the #2x file will work, but whether the image will be scaled, tiled, stretched or centered (or something else) is up to the place where it's used.
Note that the documentation says that unless you use the name without the #2x suffix and let iOS find the 2x version for you, it will set the scale of the image to 1.0 rather than 2.0, which complicates drawing. You'd have to load the image using imageWithData:scale: to fix this.

Resources