UIBarButtonItem image appears pixelated - ios

In my IOS app, I'm trying to incorporate images on UIBarButtonItems. I found some icons on IconFinder, but they appear pixelated when I specify the image using the Storyboard (I exported 22x22 pixel pngs).
It appears fine in the storyboard but pixelated on my device / in the simulator:
How can you ensure that UIBarButtonItem images are not pixelated? I've read that they should be 22x22.

They should be 22 x 22 points. You are dealing with pixels.
You need an #2x image that is 44 x 44 as well as an #3x image that's 66 x 66 if you're optimizing for iPhone 6 Plus.
Here's a helpful link about the difference between points and pixels

Related

Incorrect Assets image loads in iPad

I have added an image of three dimensions to Assets.xcassets
back.png with size 18 x 14 pixels
back#2x.png with size 36 x 28 pixels
back#3x.png with size 54 x 42 pixels
I have set the image property of UIButton as "back" in Attributes Inspector. On running the application on iPad Pro(12.9-inch 3rd generation), Xcode should automatically populate back#3x.png as image on that UIButton. But, its loading lowest resolution image i.e. back.png, on the UIButton.
Please assist as I need to load higher pixels image for iPad's.
From Apple guidelines of image size and resolution the new iPad Pro (12.9 3rd generation) uses the #2x.

What can possible cause image look ugly in tab bar iOS?

I have 2 images.
The first one (#2x: 50x50, 72 pixels/ inches) is like this:
It look so ugly in Tab Bar:
The second one (#2x: 48x42, 72 pixels/inches) is like this:
Even it is smaller, it look good in Tab Bar:
I cannot see the different between the 2 images. Can you see and tell me why? I'm new in designing images for iphone. How can I design good image for tab bar? Here you can download the images.
Now you can set that image size according to the devices you are using
Tab bar icon (optional)
iPhone 6 Plus (#3x)
About 75 x 75 (maximum: 144 x 96)
iPhone 6 and iPhone 5
(#2x) About 50 x 50 (maximum: 96 x 64)
iPhone 4s (#2x)
About 50 x 50 (maximum: 96 x 64)
iPad and iPad mini (#2x)
About 50 x 50 (maximum: 96 x 64)
iPad 2 and iPad mini (#1x)
About 25 x 25 (maximum: 48 x 32)
According to the screenshot, I am suspecting image size.
I can't tell the exact reason why because never seen document regarding that found yet.
But in the practical experience those somewhat "distort" border problem happens when the image size and the control size are different even it has 1 pixel differences.
For example,
My UIImageView size is 32x 50, and my #2x image file for that imageView is 64 x 101. This can be cases because when we slice down, original image can have this pixel differences and we keep it for aspect ratio.
In this case, the size can be said 32 x 50.5 which is actually a bit difference and then, the image is showing "distort" or "blur" at it's border
Solution is just change it's image size as required.
After hours of researching finally I found out the reason. It's so silly of myself but I have to post this with hope that it will save time for other iOS developers who also want to design their own app:
Basically when exporting images to be used inside your app, your need to export with with PNG-24 type. That's all. (See image below as an example).

How to Sharpen Images for iPhone Usage

I have some images that i want to use on my iphone application. The problem is i think that the resolution is not right cause its not sharp at all when see it on the device. This is how it looks when i zoom in a bit on it:
The idea is to use this image as an image for a UITabBarItem.
Any help and general advice on how to make it sharper & better etc.. or how to make images for iPhone devices and make #2x, #3x etc??
Thank you
The tab bar icon size will be displayed about 25 x 25 point. (maximum: 48 x 32)
What does it mean?
Assume, you would like to use an watch.pngas the tabBar icon.
So you need three icon to achieve it:
watch.png -> 25 x 25 pixel (for iPhone without retina display)
watch#2x.png -> 50 x 50 pixel ((maximum: 96 x 64 - for iPhone 6, 5, 5s)
watch#3x.png -> 75 x 75 pixel (maximum: 144 x 96 - for iPhone 6 Plus)
For more details see [Human Interface Design]
Of course, you need a vector graphic image to achieve it and export it in the 3 size. A designer should know the details.
Or you can buy some icons (/download some free icons) in your topic. Several flat icon set are available, e.g.:
www.flaticon.com
http://www.pixeden.com/free-icons-set

Supporting #3x, #2x Tab bar icons with PaintCode 2 StyleKit

I followed the PaintCode tutorials on StyleKit and I've successfully exported icons into a Swift project (code only - MyStyleKit.swift file). I'm trying to understand the relationship between the UIImage generated in code and the image sizes expected for different iOS devices.
I wired up the MyStyleKit object in the storyboards to the image for the Tab bar icon. Works great but I can't tell if the resolution of the image is adjusting depending on the device. Apple's HIG suggests the tab bar icon size in pixels should be
75 x 75 px for #3x images (iphone6+)
50 x 50 px for #2x retina image
25 x 25 px for non-retina
Firstly what canvas size should I be choosing in PaintCode initially? I guessed at putting the canvas size as 25 x 25, reasoning that I should map to the UI points size.
When I rig up the icon in Storyboards does it automatically adjust to whether it needs #3x, #2x or #1x?
Should I be setting the canvas size to the UI points size?
Any help would be greatly appreciated.
Yes, set the canvas size to 25×25 points. You can then preview the canvas at #1x, #2x or #3x (or infinite) scale.
When you ask the StyleKit for image of this canvas, the returned UIImage will have the size of 25×25 points, but scale of the current screen. That means 25×25, 50×50 or 75×75 pixels.

using 1136 x 640 images in storyboard

EDIT: Dont misunderstand. I get that I can put in myImage.png whose size is 568 x 320 and myImage#2x.png whose size is 1136 X 640 and, at run time, iOS will show the lager image if the device has a retina screen. That is not what this is about. Im talking strictly about placing a 1136 x 640 image in the storyboard.
Some details:
Using xcode 5
iPhone only app (iPhone 4 and above ideally)
Targeting iOS 7 (should keep out any iPhone 3gs ...right?)
Single view app
Using storyboards
My understanding is that I can provide only the higher resolution 1136 x 640 images my app needs for the iPhone 5 then use autolayout to constrain things in such a way that my UI works properly even if the device is an iPhone 4 and has less screen real estate.
My issue is that if I drag a 1136 x 640 image onto the storyboard the image is 2X the size of the view im dropping it into. I get that I can resize the UIImageView and set the mode to aspect fit and the image will display correctly in the view.
However, that would get quite annoying. Is there a way to just set the storyboard to use the retina images directly?
Now I can create images that are half the size (568 x 320) and those will drag and drop into the views perfectly. But I cant imagine why anyone would want to do that. This doesnt make sense to me. I would expect the SDK to let me layout the app in the highest resolution possible.
I tried using images named myImage.png and using myImage#2x.png but neither changed anything.
Don't think of the dimensions in Xcode as pixels, but points. So while you set the image dimensions to be 568 x 320, the #2x images are going to use two pixels per point.
What are you testing on? You might not be seeing a difference because you are only testing on retina devices. If you are only planning on supporting iOS 7 (iPhone 4 and up), you won't be using any non-retina devices.

Resources