What happens if iOS images sizes are not rightly calculated? - ios

What happens if I will have an 1x image at 100x100, the 2x image at 190x190 and the 3x image at 290x290? Will it make any difference?
I used Slender to analyse the images in my project and it flooded me with several warnings saying the image sizes are not right and the dimensions are a mismatch.

5 or 10 pixels doesn't make major difference when image size is 200 or 300 pixel. But, you should follow the standard(as per apple guideline) that 2x should be double and 3x should be triple of 1x respectively.

Related

images looks blurry when adding it to xcode with three sizes

when adding images in Xcode with the three sizes (1x,2x,3x),
and after that adding it to the storyboard,
the image will look blurry and unclear.
Size example
1x = 8X8
2x = 15X15
3x = 22X22
Second issue the image looks very small (like the menu icon in the image below) in case it was in the three size 1x,2x,3x,
but if i added only 3x it will be ok like the search icon
Check the actual size of the image. Just naming them with #2x and #3x won't increase its size.
Example:
1x = 100x50
2x = 200x100
3x = 300x150
A trivial suggestion: if you're not working with vectorial stuff, start from the highest resolution you have and then downgrade it to avoid loss of definition.
I mean: start from 24x24, save it #3x and then resize it to 16x16, saving the #2x version. do the same with 8x8.

Image asset size in Xcode interface builder

If I add an image view onto interface builder in Xcode and it has a size of 200 x 100 (size in Xcode), how do I know what size to make the image asset for 1x 2x and 3x.
If I make it 600x300 pixels in photoshop for the 3x and then try to use this image it doesn't look very clear on an iPhone 7 plus so how do I know what resolution the image assets should be for a given image view size
If I add an image view onto interface builder in Xcode and it has a size of 200 x 100 (size in Xcode), how do I know what size to make the image asset for 1x 2x and 3x.
Resolution is a matter of the correspondence between points and pixels. If the desired image size is 200x100 points, then you would provide these three image sizes:
1x: 200x100 pixels
2x: 400x200 pixels
3x: 600x300 pixels
If we are running on, say, a 2x-resolution device, the image will be loaded with its scale set to 2, so that 2 pixels will correspond to 1 point.
Note that you should not attempt to make the 3x image by simply upscaling the 1x image. That will obviously look terrible. You should start with a 600x300 original and downscale to get the 2x and 1x images.

How to decide 1x, 2x and 3x image sizes based on the size of the corresponding UIImageView?

My query is in two parts:
1) plain and simple, how do we decide the 1x, 2x and 3x image sizes ?
I found this SO question closest
what-should-be-3x-images-of-100x100 size UIimageView or UIButton
but there is no accepted answer in this so I am a little confused if that is really how it is
So if I have a UIImageView of size, say, 17 X 21
So will my 1x be 17X21, 2x be 34X42 and 3x be 51X63 ?
2) If it is so what the sizes would be in case my UIImageView size also varies as per screen size.
So for iPhone 4s 320X480 if my UIImageView was 17X21, for iPhone 6 375X667 it would be 20X29
So how do I decide my image sizes (1x, 2x & 3x) which are fit for all device sizes?
PS:
Really a big thanks in advance, coz this might sound a very basic question but I have really banged my head a lot over it but can't find a concrete satisfactory answer even after searching and reading a lot.
You should think in points, not pixels.
1
If your UIImageView has the size of 17x21 points then you'll need to provide 3 images 17x21 pixels, 34x42 pixels and 51x63 pixels. The OS will pick the correct one depending on the pixel density of the device the app is running on.
2
One way to decide the size a UI element is using a software like Graphic. You can draw a rectangle representing the screen and the UI element only thinking in points. This should make things easier.
It is a bit late but I understand your problem.
First you need to know the difference between point and pixel.
The point is when you in Xcode.The pixel is when you have the actual size of iPhones screen as pixel.
In 4s, 1 px equal 1 point.
In 5, Se, 6 , 1 point 2 px
in 6s, 7s , 1 point 3 pixel.
I am gonna give you 2 different example to understand this.
Example 1
You want you image 100x100 for all iPhones in Xcode.So you should make :
1x size 100x100 pixel in Ps or Sketch.
2x size 200x200 pixel in Ps or Sketch.
3x size 300x300 pixel in Ps or Sketch.
Another example answers you question.Because you have aspect radio.That means you want your image to be scaled.
You have 17x21 point for 4s then it should be 17x21 pixel.
You have 20x29 point for iPhone 6. It should be 40x58 pixel.
You have something for 6s and 7s so it should be 3 X something.
Because you have aspect ratio and scaled.It does not matter as long as you keep 1x for 4s, 2x for 5, 6, SE, 3x for 6s and 7s.
So you have 40x58 instead 34x42 (17x21) x 2 for iPhone 6.
40x50 for better resolution which Apple recommend.When you use aspect ratio, it sometimes be hard to choose the image size.If you used 32x42 instead 40x58 , there is nothing wrong with this but resolution would be less than 40x58.
Hope It works.

Confusion about #2x #3x Xcode images

The apple guides haven't helped me too much with this but I am starting to get serious about IOS development and was taken aback when I saw images go from #1x to #3x.
One source I found said they were based on sizes. For example:
If you are working on an inferred VC size and your image is 30x30 and you run that on a iPhone6 then your image should be 30x30 for #3x, 20x20 for #2x, and 10x10 for #1x.
Another source I said mentioned that it was based off the images resolution and not the size of the image.
Could someone clear this up for me and explain how to make sure my images look professional for all screens?
Thanks in advance!
When the first iPhone (and SDK) came out, all images were 1x (1 pixel of the image = 1 pixel of the screen), because that's all we had to care about. On that phone there were 166 horizontal or vertical pixels per inch (dpi). So to display an image that stretched from the left edge to the right edge, our image would need to be 320 wide (because that's what Apple told us - we didn't have to count pixels) by whatever height we wanted. Let's say 100 pixels tall. We'd name that image MyPhoto.png (because Apple told us the iPhone OS worked best with PNG images) and we'd display it.
When the iPhone 4 came out with the retina display, its retina display had 2 times the horizontal and 2 times the vertical resolution of the older phones. So now we needed higher resolution images to get the best looking interface. We were still displaying just a 2" wide image, but it would need twice the number of horizontal pixels and twice the number of vertical pixels (4 times the total number of pixels) to fill the same space. So now our image needs to be 640 pixels by 200 pixels. Since our app would still need to support the older phones as well as the new phones, we didn't want to just replace the old image with the new one. We needed a way to support both. So the old images kept the same name they had before (we didn't append "#1x") and the new images got the "#2x" filename extension to indicate they were twice the resolution. So we'd name this larger image MyPhoto#2x.png.
A common question is why not use just the higher resolution images on both old and new phones? With scaling, both appear to work great. The problem primarily is that the iPhone, especially the older phones, had very limited memory to work with. Using images that are 4 times larger than they need to be is really hard on that limited memory. That's why we had to have both 1x and 2x images in our apps.
For our sanity, we would still just use 1x while designing the interfaces. So screens remained 320 pixels wide in our code, even if we were going to display them on a retina display that was 640 pixels wide. If we wanted to draw a 1 pixel wide line on the retinal display, we'd make it half a pixel wide in our code.
With the larger screen of the iPhone 6 Plus, Apple had to pack even more pixels on the screen to maintain the high resolution customers came to expect. So now we're into 3x images. However, the iPhone 6 Plus doesn't really have three times the number of horizontal or vertical pixels. But again Apple has kept us sane by just asking us to supply "#3x" images, and it worries about scaling them down a bit on the device. As before, we still need to support smaller screen resolutions too, so we still include "#2x" and the 1x images in our apps.
So, to continue our example, the #3x image would need to be three times the width and height of the 1x image. So now we need a 960 wide by 300 pixel tall image. We'd name it MyPhoto#3x.png.
Notice that although I mentioned earlier something about a 166 dpi display, that's not really important when creating these images. In your photo editing app you don't really care if the image is 166 or 72 dpi or anything else. The only important part is the number of pixels in width and height of the final image we export.
So to answer your question (hopefully), you'll want to include all three of these images in your iPhone compatible apps. You can skip the #3x image for iPad-only apps, because there's no 3x screen yet for the iPad. But continue to think only in the 1x size when working in Interface Builder and code.
For example, now to display a 1 pixel wide line on the iPhone 6 Plus, you'd draw a 0.33 wide line rather than a 1 point line. Of course, you still want to support all of the other screen resolutions too, so you'd use code like this to set your line width:
let lineWidth = 1.0 / UIScreen.mainScreen().scale
This will give you 1.0 for the non-retinal iPhones, 0.5 for the iPhone 4, 5 & 6, and 0.33 for the iPhone 6 Plus.

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.

Resources