Image in Storyboard LaunchScreen isn't retina - ios

I'm creating a launchscreen with Storyboard, and am using a UIImageView. I specify the image named, and when my app opens, the launch screen shows a blurry version of my image (it's not using to 2x version of the image).
I later programmatically show the same image using [UIImage imageWithName:#"name"], and it shows retina as expected.
The image is saved in an Image Assets file, and I specify the #1x, #2x, and #3x versions.
Any ideas?

Related

Image assets appearing at wrong resolution on iPad Pro

I am using tabbar controller. I have added tabbar item images to image Assets as 1x, 2x and 3x respectively.
When I run the app with iPhone and iPad, it is normal. The 2x image size is 60*60 and tabbarItem. Image shows 60*60 for iPad. But when it comes to the iPad Pro, it is showing 30*30. Could any one explain why this is happening and how to resolve it?

Use static image for launch image iOS 9 from Asset Catalog

I'm trying to use a static image on my LaunchScreen.storyboard, so we need unique sizes for each device.
In my assets folder I can great a launch image Image Set that allows me to add images for each device, however I just get a blank launch image when I use these in an Image View. A regular image doesn't give enough options (only 1x, 2x, 3x for iPhone/iPad). What's the best way to do this?
To clarify: how can I use a full screen static image that fits on say both a 4S and iPhone 5 when both those images are technically 2x? Creating a new launch images asset gives all these options for different screen sizes, however it can't be used in storyboard as an image like a regular asset.
Instead of using the LaunchImage set, add a normal image set of the image that you want to be on the launch screen to your .xcassets file. Next, add a UIImageView to the UIViewController in your LaunchScreen.storyboard and set the image using the Attribute Inspector.
Step 1: Add your image assets to the .xcassets file
Step 2: Add a UIImageView to the LaunchScreen.storyboard file
Step 3: Add constraints to the UIImageView and set the image in the Attribute Inspector
BTW, don't forget to make sure that the Launch Screen File in your .xcodeproj is set to your LaunchScreen starboard file!
You should now be good to go!
UPDATE: Static Launch Image using only the .xcassets file
If you want to use a full screen static image on launch, you can use just a LaunchImage set in your .xcassets file.
If you don't already have a .xcassets file in your project, add a new file like so: File > New > File > iOS Resource > Asset Catalog.
Next, open your .xcassets file and right click > App Icons & Launch Images > New iOS Launch Image
Now you can add specific launch images for iPhone 4(S), 5(S/C), 6(S) and 6(S) Plus. (BTW, I've selected only the portrait orientation for this image set).
The last, and very important step, is to leave the Launch Screen File field in blank in your target settings!

blurred icons on ipad

I have images supporting 1x, 2x and 3x.
Images are placed into an image set into the respective 'containers': 1x, 2x, 3x.
In Image attributes, I selected 'universal'.
However, during testing we can see that the images are blurred on an ipad (tested with ipad 2).
Not sure what am I doing wrong. Do I have to explicitly select device image set (e.g. ipad image set)?
Do I have to explicitly append 1x, 2x and 3x to the image name? For example, my-image#2x.png?
I have no issues across all iphones (4S, 5, 6/+, 6s/+, se).
I looked at various answers including this one but I am still not clear why my images are blurred on an ipad.
App icon is NOT blurred!
Icons are added to the view as follows:
toolbar items - images are set in storyboard using the image set name
tab icons on UITabBarController - added via storyboard using the image set name
map annotation callout - callout button image set with:
leftButton.setBackgroundImage(UIImage(named: navigateCue) , forState: .Normal)
Should also state that all my icons follow these guidelines provided by apple.
Also, on a simulator everything is fine...
This is how my folders are set:
In Images.xcassests I have a directory called multi-res.
In this top level directory I have sub-folders associated with the 'role' of the images (e.g. toolbar).
Each of the subfolders contain image sets (e.g. pins). An image set is named as 'red' (for red pins).
Within each image set I have 3 images: <base>.png, <base>#2x.png and <base>#3x.png
I have checked all images in both finder and sketch. They are exact in size and multiples. So if the <base>.png is 24x24, the <base>#2x.png is 48x48 and the <base>#3x.png is 72x72.
Everything works fine on all iphones (4s, 5, 6/+, 6s/+, se) and new ipads.
The issue remains with old gen ipads such as ipad 2.
I followed apple's guidelines stated here.
Do I need to create images with ~ipad extension too just for ipad2?
Do I need to have a #2x-1.png, #2x-2.png? If so, how do I create all these folders under an image set?
Something else?

iOS tab bar icons are blurry

My tab bar icons appear blurry.
I created the icons using Photoshop, and followed the iOS Human Interface Guidelines when I decided the sizes of each icons.
e.g. icon size: 30x30px png
This only happens with the tab bar. I wonder if this happens because of the resolution of the images or because of programming issues...
You're using icon size 30x30 which I assume is for 1x (iPhone<4). Since iPhone>=4 needs 2x and 3x images so you have to include that also.
Either you use images with naming conventions like
star.png // 1x = 30x30
star#2x.png // 2x = 60x60
star#3x.png // 3x = 90x90
or you can use image.xcassets and put your 1x, 2x and 3x images there and use it.
Reference Xcode Assets Catalogs
Probably because using a device with the retina screen.
Try about changing the icon's filename to xxx#2x.xxx like "facebook_icon#2x.png".
Also, be aware that you can use a PDF file (vector graphics, resolution independent) instead of PNGs, and Xcode will render the appropriate resolutions at build time for you (I don't think you can easily do this for third party icons such as Facebook, but...).
To see how this is done, create a new project using the "Tabbed Application" template, and check the asset catalog for the tab bar icon images. It does just that for the circle and square icons of the "First" and "Second" initial tabs.
Use this line of code to set image for uitabbaritem in uitabbar .
tabbaritem.image = [[UIImage imageNamed:#“image”] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

Unable to properly load iPhone 4" image

My application, which should support iOS 5.0+ I have background UIImage, which should be load proper image depending on device. So I've created 5 images with corresponding resolutions.
img.png
img#2x.png
img-568h#2x.png
img~ipad.png
img#2x~ipad.png
Also I've set Default-568h#2x.png splash image. I then detect in viewDidLoad which device my app is running and use
[bkgImageView setImage:[UIImage imageNamed:#"img.png"]];
to load appropriate image. All resolutions are loading just fine except iPhone 4" one, which is img-568h#2x.png. If I load this one explicitly
[bkgImageView setImage:[UIImage imageNamed:#"img-568h#2x.png"]];
the scale is not correct. So how can I load 4" retina image automagically or manually?
Adding -568h to the end of the file name doesn't work. The only supported modifiers are #2x,~ipad, and ~iphone. The only case where -568h might seem to work is the launch image, where the image must be specifically named Default-568h#2x.png.
You should use auto layout (or struts and springs) to adjust your screen accordingly.
Your problem is that it's automatically stretching an image that's already large enough.
The solution:
If you load the image explicitly for that device, you should load "image-568h", and let it automatically add the #2x. That way, it knows that it's a high resolution image and doesn't attempt to stretch it.
Additionally, rather than detect the device, you could design the image with the extra space at the bottom to fit the 4" screen, set the image to Aspect Fill, and let it clip for smaller devices.

Resources