XCode 7 different images resolutions - ios

I have an iOS application supports iOS7+, i am using now Xcode 7.
I have multiple image sizes to use for iPhone 4s, 5, 6 and 6plus sizes...
I am using image assets in XCode, but i found only 3 image nodes: 1x, 2x and 3x.
How to manipulate these different sizes with these only three options in image assets?
Edit:
in the story board; i have single viewController (assumption), this viewController contains single image, how to create single image set and put all images in this set and in the run time, every device takes its suitable image size?

In the "image assets" section of Xcode, you can add a different image set for each distinct image that you need in your app.
To add another image set for a different type of image you just click on the plus button in the bottom left of the image assets view, and then click on "New Image Set" (see image below).
From there you can add as many image sets as you would like, with the 1x, 2x and 3x for the respective devices. The 1x size represents images that will be used for non-retina displays (everything previous to the iPhone 4). Then the 2x size is used for all phones after that except for the iPhone 6 plus and 6s plus (those two use the 3x size).

Hope below mentioned link helps:
https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html#//apple_ref/doc/uid/TP40006556-CH27-SW1

Related

Size of image to set as Background image in view controller

I am trying to put a background image on a UIViewController.However i cannot figure out the size needed because the image should support devices from iphone 4s to iPAD...Here are few questions:
1) Should i put those large image on image xcassets on 1x,2x,3x size,if so what should be the size of those images?
2) Or Should i Copy a high resolution image on the bundle itself again if so what should be the size?
We have differnet-2 sizes in assets like here:
(Only for iPhones)
What I found is that, you should opt for first option and 750X1333, 1080X1920 and 1242X2208 should be the 1x,2x and 3x.
You can add more by clicking on tick sign and give sizes like above we give for the iPhones.
Designer will give you proper sizes with respect to resolution to each ipad and iphone
Well it depends on what kind of image you want to display
If it's a solid or pattern image that won't have any different if scaling up / down then I suggest that you put it in image xcassets and use for all supported devices. You should put the largest size image, you can find all screensizes from this: http://iosres.com/
Otherwise, if it's a picture with details like a portrait or food dish, etc. You have to drop it manually with some photo editors like photoshop then add it to xcassets separately for iPhone and iPad
In place of 1x,2x & 3x images take single PDF image and place in image assets it ll fit for all comparability devices.
I think this code will help:
var backGroundImageView :UIImageView! //declare
///set image contentMode in viewDidLoad()
self.backGroundImageView.contentMode = .scaleToFill
However, you should check whether the image is in landscape or portrait orientation.
Image xcassets on #1x,#2x,#3x size will match iPhone 4S screen size automatically, #2x is for the iPhone 5, #3x for the Plus.
As for the iPad you can check the Apple Developers documents.

full screen image sizes and naming in xcode

I'm a bit confused here. If, say, I want to set an image as background (full screen) for my ios app (iphone), what are the sizes for the image I have to make? I googled and found no clear answer yet.
Using image assets gives no explanation either. I tried creating new image set, it just shows 3 slots for 1x, 2x, and 3x. How the xcode differentiate between what image to use for iphone 5 and iphone 6 (different ratio)?
EDIT
I seem to be unclear about my question. If the image for iphone 5 and 6 is the same, doesn't the aspect ratio differ? It will be stretched on one device or vice versa on the other and I don't want that. Back before the iphone 6, I just create image .png, #2x.png, and -568h#2x.png with the size 320x480, 640x960, and 640×1136. So my question is, for iphone 6 and 6+, what is the naming and size for my images?
If, say, I want to set an image as background (full screen) for my ios app (iphone), what are the sizes for the image I have to make?
You can use [UIScreen mainScreen].bounds's width & height to setup your view frame.
it just shows 3 slots for 1x, 2x, and 3x
They're not used for handling ratio of displaying, just for display solution (retina or not). You can just use xxx.png in your code, and it'll choose to use xxx#2x.png or xxx#3x.png appropriately.
How the xcode differentiate between what image to use for iphone 5 and iphone 6 (different ratio)?
UIImageView has an instance method called -setContentMode:, you can use UIViewContentModeScaleAspectFill mode for displaying in different devices w/ different ratio, i.e., some parts will be cut off.
This link should give you an overview of the differences between the 1x, 2x and the 3x image assets which we get once we create a new image asset.
http://9to5mac.com/2014/08/29/support-for-3x-image-assets-found-in-latest-ios-8-beta-ahead-of-larger-display-iphone-6/
Also when you create a new image asset, you can select image for specific devices such as (iPhone and iPad), if you are only developing for certain devices.
Select the devices as "Device Specific" from the Image Set Shown on the right side of the image.
As for you question, iPhone 5 and iPhone 6, xcode will take the same image assets i.e. 2x, for iPhone 6 Plus it takes the 3x image.
App Icon and Launch Image
Now for the App icon and the Launch image, this following link will guide you through.
http://www.iphonelife.com/blog/31369/unleash-your-inner-app-developer-managing-images-xcode-5-asset-catalogs
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html
for the launch image there are different options available, such as you can individually set images for the landscape and portrait images for different devices.

How to use image assets for different sized iphones

I wanted to know that how we will manage images assets for different sized iphones in xcode,suppose i have an image name abc.png for iphone 5
abc.png non 20X20
abc#2x.png 40X40
as i can set image name abc.png in xib but as size of iphone 6 and iphone 6+ is different so how i can use abc.png for those large size iphone
I have images for all resolutions
abc.png (for iphone 5)
abc6.png (for iphone 6)
abc6plus.png (for iphone 6+)
i have below doubts in my mind
1. i have to mannualy set image in code for iphone6 and iphone 6+ by checking the screen size?if yes then please let me know do i have to use only one image that is 1X or have to add 2X image also for all device
2.i think that as these iphone5,iphone 6 and iphone6Plus are retina displays so i should use only 2X images for these displays?
3.Do we have to use images like giving then name of image in xib abc.png and placing the abc#2x.png for iphone 6 and abc#3x.png for iphone6+ in bundle only and xcode will pick corresponding image at runtime?
Please suggest
You can use UIImageAsset
A UIImageAsset object is a container for a collection of images that represent multiple ways of describing a single piece of artwork. A common use case for UIImageAsset is the grouping of multiple images of the same item at different display scales.
As you said
3.Do we have to use images like giving then name of image in xib abc.png and placing the abc#2x.png for iphone 6 and abc#3x.png for
iphone6+ in bundle only and xcode will pick corresponding image at
runtime?
you just need to add different resolutions of same image in assets(Images.xcassets) ( i.e abc.png , abc#2x.png and abc#3x.png ) the rest of work will be automatically done by assets and xcode.
check out this
iPhone 6 Plus resolution confusion: Xcode or Apple's website? for development

Xcode 6 - xcassets for universal image support

Currently working on a universal SpriteKit project. I'll be supporting the following devices:
iPhone 4/s,
iPhone 5/c/s,
iPhone 6,
iPhone 6+
iPad non-ret,
iPad retina
I am confused on the iPhone part. I already have 4 versions for my background sprite for the 4 different screen resolutions of the iPhones. But which goes to which?
I know the 3x is for the 6+, and I think the 5/c/s goes to the Retina 4 2x, but I do not know where the iPhone4/s, and 6 go. Anyone know?
Side note, when I create a Launch Image inside my xcassets file, I am shown these options, which basically has all the device I am supporting. Just wondering why this is not also the case when creating an Image Set
Also how do you guys approach creating images/sprites for a universal application? Now that the new iPhone 6, and 6 plus are out, I have 2 more resolutions to support which is still confusing for me as I'm still a beginner.
This is a little confusing - here's how I understand it (this is in reference to the top image):
1x images are for the original iPhone through the 3GS - 'standard' resolution devices (3.5" screens)
2x images are for the iPhone 4 and 4S (3.5" Retina screens) and are also used for the iPhone 6.
Retina 4 2x are for the iPhone 5 and 5s (4" Retina screens)
3x images are for the new iPhone 6+ (5.5" super-Retina [3x] screen)
I believe that the iPhone 6 (4.7" screen) will use the Retina 4 2x images, but I would have to test it.
Side note, when I create a Launch Image inside my xcassets file, I am shown these options, which basically has all the device I am supporting. Just wondering why this is not also the case when creating an Image Set
If you compare the two images, the lower one has everything the upper one does, except for a 1x iPhone graphic. You don't need that if you're only supporting iOS 7 and above, since iOS 7 doesn't run on any non-Retina phone-form devices. To be honest, I don't understand why the top image has a 1x iPhone form graphic option - maybe because you checked the "iPhone" box in the sidebar?
Also how do you guys approach creating images/sprites for a universal application
For most non-fullscreen images (like a logo), you really only have 3 resolutions to support - standard (1x), Retina (2x), and the iPhone 6+ (3x). These are simply different quality of images, not really different sizes. So if you have a 10x10 image on a standard device, that would mean you need a 20x20 image on a Retina device and a 30x30 image on an iPhone 6+. On all devices, they would show up as a 10x10 image.
A great tool I used for managing different resolutions of icons is iConify.
I create them at the highest size I need (30x30 [#3x] for an image I want to be 10x10 on a device), then save it as a png and resize copies to 20x20 [#2x] and 10x10 [standard]. A better solution would be to create and use vector graphics, which would resize better to any size.
In 1x place image with resolution 320 x 480.
In 2x place image with resolution 640 x 960.
In Retina 4 2x place image with resolution 640 x 1136.
in 3x place image with resolution 1242 x 2208.
Images of Retina 4 2x will upscale to resolution 750 x 1334.
Images 3x will downscale to resolution 1080 x 1920.
You can also visit this links for launch screen images:
http://www.paintcodeapp.com/news/iphone-6-screens-demystified
http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions
For all other images resolution and size:
https://developer.apple.com/ios/human-interface-guidelines/graphics/launch-screen/
https://developer.apple.com/ios/human-interface-guidelines/graphics/image-size-and-resolution/
https://developer.apple.com/ios/human-interface-guidelines/graphics/custom-icons/
How to use Image.xcassets:
https://www.youtube.com/watch?v=_36Y6rDcKP0&list=PLXCowKcXAVgrCe2Lezv0acRf4adQLshv2
Hope this will be more helpful.
If you have your launch images in an xcasset file, you can do the following in Xcode 6.
Select the launch image asset, select a specific resolution (1x, 2x, Retina 4, etc) and open the attributes inspector (see image below).
Under the "Image" section, you will have a "Expected Size" attribute.
Inside images.xcassets, you can add different devices support by right clicking as shown in the snap
Edit: Well, it doesn't seem working when I drag n drop images to placeholders. It gets messed up as shown next
I don't know why it is acting odd on my Xcode 6.4 though.
Edit#2:
I see a bug from apple here. I can select 'Universal' along with any device upon right click as you can see in the first image above. But via attribute inspector I can correctly select either 'Universal' or specific devices as shown here
Edit#3:
In Xcode 7 the attribute inspector has been changed and now it gives option same like the right click. So instead of either 'Universal' or specific devices, now it offers to select all.
There is one tool : AVXCassets Generator with which you can directly generate XCAssets file for all your icons and images just by one click.
hope you will like it.

Setting the correct full-screen image as my launch screen xib

We want to support iOS 6 through iOS 8. By my count, that means we need to create ten launch images.
portrait 2x3: 320x480 640x480
portrait 9x16: 640x1136 750x1334 1242x2208
portrait 3x4: 768x1024 1536x2048
landscape 16x9: 2208x1242
landscape 4x3: 1024x768 2048x1536
What I wish is that I could just generate the largest sized image at each ratio, and that iOS would just downsample the image for the other sizes. That would save me from adding five more launch images to my app, a nice savings in download size.
Is it possible to use the new feature of Xcode 6 to replace my launch images with storyboards (aka UILaunchStoryboardName) to do what I want?
It seems pretty close, but I can't figure out how to say, "At 2x3, use image X; at 9x16, use image Y; at 3x4, use image Z" and so on. Size classes don't seem to let me express that concept cleanly. (Or do they?)
Here is one way to do this... Create a new image set in your existing or some new assets catalog. By default, the Devices field of the new image set, in the right pane, will be set to Universal, and so you should see three image wells in the main view: 1x, 2x, and 3x. What you want is to set the Devices field to Device Specific, then check iPhone, Retina 4-inch, and iPad underneath that field. Then, you will now see six images wells. There are four for iPhone: 1x, 2x, Retina 4 2x, and 3x. There are two for iPad: 1x, and 2x. Now, all you have to do is to drag your versions of the same splash image in various device-specific sizes, into the appropriate image wells. Once you are done, go to your launch screen XIB, which by default is set to Any width and Any height, and add a UIImageView, setting the image to have the same name as the image set you just created. Adjust the image to have the same size as the enclosing view, adding top, leading, bottom, and trailing constraints with a constant value of 0, so that the image size adjusts with the view size, regardless of the device. Run the app on your device and you should see the correct splash upon launch. You can set a breakpoint at the top of your AppDelegate code, e.g. right underneath the var window: UIWindow? declaration (or equivalent if using Objective C), so you can verify the splash on different kinds of device. Note that the image may not work in the Simulator, so try on a device. I guess that it is a bug in the Simulator, or unimplemented feature.
One thing I am not sure about is where to specify the image for iPhone 6. It seems that there are device specific image wells only for iPhone pre-4s, iPhone 4s, iPhone 5, iPhone 6 Plus, iPad, and iPad Retina sizes.

Resources