iOS images sizes - ios

I'm having doubts regarding the size of the images at different resolutions.
Example:
I have a button in the GUI I inserted it in size 100x50.
My background pictures for this button to 1x, 2x, 3x must be of sizes which? In px or pt?
I did some tests and insert them for their size 100x50 1x, 2x and 3x 300x150 200x100 (in px). But the images were of poor quality.
PS: I've seen the documentation but also those doubts were not very clear

You should use:
1x - 100*50px - image.png
2x - 200*100px - image#2x.png
3x - 300*150px - image#3x.png

I think problem with naming better you Use the assets catalog. Xcode will manage the #1x, #2x, #3x easilly or name the images properly as
image_name.png (for 1x image)
image_name#2x.png
image_name#3x.png
for more details about image resolutions take a looks on this and apple's ui guidlines

You can use a simple vector graphic, png or icns format. Now there a different options to convert your picture in hte #2 and #3 format. You can use e.g. the App 'Prepro' -> it's for free in the App Store. This App will create your needed icons

Related

Ideal image size for iOS

If I want to display an icon with 24x24 in an app, what sizes should I provide in the app?
For example, is it sufficient to save the image as 128x128 in the app?
Or are #1x #2x #3x sizes required?
It is a simple icon (width == height), example:
Different sizes are not necessarily required, but they can help reducing binary sizes.
For an image that you want to show in the dimensions of 24x24, you should provide a 24x24, a 48x48 and a 72x72 image.
For simple graphics like this, it's usually more suitable if you create a vector asset.

iOS resizableImageWithCapInsets & #2x, #3x images

I am creating a 'chat bubble' using this method, by setting the background image after calling resizableImageWIthCapInsets. However, for this method you need to hardcode the cap insets by pixel, but the pixel size is different for each 1x, 2x, and 3x image size. How do I get around this issue? Is there a way to know which image the device is using (the 1x, 2x, or 3x)?
You don't need to do it in code. Xcode has a special tool for this. Check this link, in the section named "CAN I GET THOSE IMAGES FOR THESE BUTTONS, BUT LONGER?" or here. There are explanations how to use it.
If you use this you can not care if image is ready to display or which resolution you should use.

How to cut iOS8 assets from a PSD designed at 1242px by 2208px

The designers on a project I am responsible for developing (one of my first iOS projects) designed the app using a Photoshop canvas set at 1242x2208 pixels, which is the number of pixels that the iPhone 6+ uses. I've scoured the internet and am just getting more and more confused by all the conversions for 1x, 2x, 3x and to further the confusion, apple downsizes to 1080x1920.
Anyways, how do I cut the assets correctly for #1x, #2x, #3x? When I crop the element I want, I save it out at 3x. But what do I divide by to get the 2x and 1x versions?
Here's secondary question and a hypothetical situation: There is a button that is designed to be the full width of the screen in portrait, so the designer made it 1242x100. If I save it out at 3x, then scale it down for 2 and 1x, will this button fit all the different screen sizes all the way down to iPhone 4/4s, which has a smaller pixel dimension and different aspect ratio?
Confused, any help appreciated!
Example:
If you original artwork is 960px by 1704px, just save you image including "#3x"
image#3x.png // (960 x 1704)
Then you have to resize it to 640x1136 and save including "2x"
image#2x.png // (640x1136)
And then you have to resize it to 320x568 and save as 1x
image.png // (320x568)
Indeed the Retina sizes are confusing, but this is what auto resize is used for in Xcode.
But The API which Apple give us, chooses the #3, #2 and 1 sizes by itself. There isn't anything that the developer/designer needs to do but provide all three images. An example is:
ObjC:
+ (NSImage *)imageNamed:(NSString *)name]
Swift:
init?(named name: String) -> NSImage
Would just use the name of the image without the # etc... So, myImageName#3x.png myImageName#2x.png myImageName.png would just be referred to as "myImageName"
The API handles the rest :)
I have had the same problem. What I did was, after cutting all images for iPhone 6+(#3x), I just resized the PSD to iPhone 5's width which is 640px, (height would be 1138 px if you keep aspect ratio) and cut #2x images. For the 1x images, again resized to 320px width.
Just, iPhone 6+, iPhone 6 and iPhone 5 have almost same aspect ratio.
Good Luck!

Confused regarding #3x artwork for iPhone 6+

I have an app in the App store to which I want to add #3x files. I read various posts but I am not sure how to proceed.
I read that coordinate space for the iPhone 6 plus is 414x736 points, (X3) that yields 1242x2208 pixels and not 1080x1920. Also I read that the iPhone 6+ will divide that by 1.15 before rendering to the display which will make it fit.
So lets say my App has a button image that is 44x44 pixels (the #2x file), then I should draw it as 44/2*3*1.15 to make it fit my 1242x2208 photoshop canvas. (/2 for points, times 3 for pixels *1.15 to overscale)
Now Apple documentation says #3x button need to have 66 pixels area, so that seems too small as it is not scaled up by 1.15.
This leads me to think my App canvas should be 1080x1920 which would avoid the iPhone having expensive rescale. So which is right? of course #3x would not be #3x.
Forget the 1.15 thing or actual screen resolution. Just scale up your '#2x' assets by a factor of 3/2, and name them '#3x'. The rest will be taken care of by iOS.
Check these links - how #3x image is works with 1080x1920 size..
http://aten.co/2014/09/12/designing-from-iphone-5-to-iphone-6-iphone-6-more-than-i-bargained-for/
You have to set images in image asset, so iOS automatically assign 2x & 3x images.. for different devices.

iOS SDK retine images vs using bigger images for smaller placeholders

Is it the same if I use a big image i.e. a 40x40 image in a 20x20 place holder or a #2x image for retina?
I mean, I have two alternatives:
- use a 20x20 image.png and 40x40 image#2x.png
- use a 40x40 image.png
Is it the same?
Thanks.
Using only retina images and leaving the down-scaling on non-retina devices up to the system is possible but not recommendable in all cases.
It really depends on the contents of your graphics. If, for example you are using vector based graphics as your source (sharp lines etc.), then offering only the retina images will result into washed, blurry images on non-retina displays.
Again, it is possible and entirely fine if your content still looks good enough.

Resources