How images are used from xcassets? - ios

I am having icons for the app stored in xcassets for all 3 versions (#1x,#2x and #3x).
Size of an Asset: { #1x: 28, #2x: 56, #3x: 84}
But when I was trying to read the image size of one of the xcasset item in iPhone6, it showed me 28, which is the size of image to be loaded on iPhone4. I wish to know, if this is the behaviour of iOS or something's wrong on my side.
Thanks in Advance

May be you have put wrong asset in #3x place in your xcasset
and also There is one tool : AVXCassets Generator with which you can directly generate XCAssets file for all your icons and images just by one click.

UI Measurements in UIKit are performed in points instead of pixels. For example, retina screen have 4 pixels per one point, so if you try to read the size of your image at iPhone 5 for example you will get 28 points. On iPhone 6(s) Plus screen is even denser and thats why there is requirement for #3x images.

Related

Images sizes for different screen

I have developed the IOS app, and it is my first app ever. I have 2 real devices. Iphone 5 and Iphone 6 plus.
I have created a UITable and in that under the custom cell I am showing small images let say 20 * 20 to represent something followed by its text.
For example I am using location icon and then I write its location in string. and both are horizontally aligned in a cell.
when I run it on the emulator Iphone 8, it shows the icon and the
screen design is as expected. but when I run it on my both devices it
is not showing me icons there it is only showing location in text form
but location image is just not there in both devices.
So I know I am doing something wrong so my summed up questions are
What is the size should I select as image/icons like button icons ?
how to put images in the project? I know it is like drag and drop in assets file? but is not there a way ?
I am not getting on how to make image and then postfix it with #2x #3x and from which size I need to start and then How to do it ?
I followed a tutorial over youtube but that was for app icon, and my app icon are visible on each devices, and looks good. But I am really confused about other icons that I have to use inside the app. and about their sizes and about how to put them in project
Please help me, and discuss it with me instead of links of pages because I have read too much on it but still a dumb head. please help me
Here is how to add an image to your project:
In the Project Navigator, open the Assets.xcassets by double-clicking on it.
Control-click in the blank area below AppIcon and select New Image Set from the pop-up.
A new asset called Image will appear. Click on Image and give it the name you want to use, (for example "house").
Drag and drop 2x and 3x PNG images into the appropriate spots. If your image is 20 x 20 points on screen, then your 2x image should be 40 x 40, and your 3x image should be 60 x 60. It is up to you to make sure those images have the proper detail and are not just scaled up low resolution images. (See Xcode images explanation for more background on 1x, 2x and 3x images).
In your code, you can load the image with let image = UIImage(named: "house") and iOS will select the proper resolution image for your device. The iPhone 5 will use the 2x version, and the iPhone 6 Plus will use the 3x version.

iOS - One Vector Image for All iPhone Resolutions

I am trying to create one vector image for all screen sizes of iPhones. I created pdf file using Illustrator with size for iPhone 6 plus i.e. 1242*231 (231 is my required height of image) and Included it in image assets and changed scaling factor to Single Vector.
Now it is being displayed in iPhone 6 plus with no problem. But when i try the same Single Vector Image in iPhone 6 it is squeezed.
I found out on web that pdf image is converted to #2x and 1#x automatically. like if i have 300*300#3x it is converted to 200*200 and 100*100.
According to this then it is the right behavior because 1242/2 = 621 and it required 750 to display accurately.
But my question is that wasn't the vector image suppose to adjust it? Any other work around this problem?
Try to save it in svg format, this would be better solution.

How do you resize a PNG without losing clarity and sharpness?

I need a few icons for my navigation and tab bars on Xcode 6, so I downloaded a few icons from:
https://icons8.com/web-app/new-icons/all
Yet once I download them and open the file, every size seems pixelated and not as clear cut and sharp as it looks on the actual website.
Why is that? What would be a method to download it just as how it looks and resize it to use it for iOS mobile application? Any insight or help would be appreciated.
Try placing them in the 2x or 3x size in your .xcassets
The 1x size is equal to the amount points on your screen (not pixels). The iPhone 3GS has 320 points in the width so the amount pixels are also 320. The iPhone 4 which has a Retina display also has 320 points, but the actual pixels are 640. So retina needs 2x and the image file needs to be 2 times larger than you expect them in points on your screen. Same for 3x.
I usually work with vectors, you can use them in Xcode as .pdf file, you can scale them as you like without getting blurried images.

Xcode 5.02 Photoshop icon creation

I am currently trying to push an app to the store (Build > Archive), but it keeps complaining about sizes of icons and certain sizes not actually existing.
I cannot find a slot in the Images.xcassets > App icon for a 120 or a 152, so first where do I put these icons so that it builds correctly.
Secondly, this is ridiculous, is there a photoshop script I can use that does the same icon up in 120, 152, and whatever other sizes it needs.
App script for photoshop
http://www.appsbynight.com/2012/09/17/create-every-ios-icon-for-your-app-with-a-photoshop-script/
Not used it, as I have a program on the Mac that converts it for me from a large image to smaller ones.. see below and is free...
https://itunes.apple.com/us/app/prepo/id476533227?mt=12
also the images to have #2x for the larger ons
so
icon-60.png
icon-60#2x.png (120 sized one)
This is not ridiculous.
2*60 = 120
2*76 = 152
Note that's said in "points" and not pixels. You have to check for the coefficient (x2 for Retina Display). Plus, since in iOS7 sizes changed, all iPhone/iPod Touch which can have iOS7 are Retina (that's why there is only the "x2" for iOS7 iPhone). For iPad, there is iPad Mini (non-retina).
I have modified an old photoshop script to create icons that have a size that matches the requirements in xcode 5.2
https://gist.github.com/derpest/8437300
Adding the correct icon to the correct place stops the errors upon validating to push to store.
A good explanation of this is explained here: 'Missing recommended icon file - The bundle does not contain an app icon for iPhone / iPod Touch of exactly '120x120' pixels, in .png format'
If you want an automated way to make your icons at all the right sizes, check out the App Icon Template. It’s a Photoshop file and a companion action that let you design your icon once, then export it all at once. Be warned that you may want to tweak your icons at each individual size to get the best look, but this is a good starting point because it lets you quickly preview your icon at all sizes.

Can I use just 2 sets of background pictures for my app and still support iphone 5?

I have 2 files called image.png and image#2x.png sizes: 320x568 and 640x1136.
If I use those files as background, does this solve the dead space on the iphone 5? Will the iphone 5 load the #2x picture? I understand that in an iphone with 3.5 and lower the background picture will get cut but I don't really care about it.
I have a project that is for both iPhone 5 and the four. For my background image, I made a uiview that was the size of the entire view. I then hooked this up to my background jpeg file. Under mode in the attributes inspector, I selected scale to fill. Since the uiview is held to all sides of the view, it works for both. It looks great in either size screen. The jpeg is pretty high res, but I didnt need to place any #2x. Hope this helps you out.

Resources