Selected tab bar icons look fuzzy if not on Retina display - ios

I am working on an iPhone app that has a tab bar. I made the tab bar icons using a vector graphics editor and exported them to PNG. The icons look fine, except when selected.
This doesn't happen on the retina display.
I use self.tabBarItem.image = [UIImage imageNamed:#"Symbol"]; to set the image.
Here is the actual PNG: http://i.imgur.com/dBTDe.png (though it happens with all the images).
What can I do about this? Why does this happen?

This appears to happen when the images don't have a margin. If you add a margin of 2px it will look fine:

You should have 2 copies of the image. One for normal or older devices, and one for retina display.
Your images should be named accordingly.
image1.png // older devices
image1#2x.png // for retina display. #2x is case sensitive as well
When you choose your image, be sure to choose the normal image. The OS will select the #2x image if it is capable of displaying it.

Related

WatchKit Force Menu Custom Icons Blurry

I'm creating custom icons for the WatchKit Force Menu. The documentation says to use an 80 x 80 size image with a drawing area of 54px square. All that works fine, but my image, when displayed in the button, looks very blurry compared to the built-in button images.
I'm creating them in Illustrator at 80px square. Saving as a .png image like the documentation says. Sizing is correct when saved at 72 dpi. If I do anything higher it causes the image in the button to be too large. I cannot find a way to scale the image.
Has anyone run into this? It seems like I would want to use a higher resolution image here or vector graphics.
You need to save the file with #2x in the filename to support retina displays.
So if your filename is myicon.png rename it to myicon#2x.png. In code you just use myicon for the name, Xcode automatically picks the correct size.
For iPhone 6, #3x is required...
I would recommend to use the Images.xcassets in Xcode for maintaining all images. There are templates for all needed resolutions (#1x, #2x, #3x, ...). Create the icons in these several resolutions and drag the files from finder to the placeholders. Later in your code you simply use the name of the image set in Xcassets.

UITabBarItem Image misaligned

My app has tab bar. I'm trying to customize the tab bar item by changing it's image. I created an image with size 106x49. The image is being placed using this code:
((UITabBarItem*)[self.tabBarController.tabBar.items objectAtIndex:0]).image = [[UIImage imageNamed:#"TabBarItemNow"] imageWithRenderingMode:UIImageResizingModeOriginal];
[((UITabBarItem*)[self.tabBarController.tabBar.items objectAtIndex:0]) setTitle:nil];
When i run the app, the tab bar item image looks like this:
Is there a way to fix this? Am i choosing the right image dimensions for the bar item? Besides, the image looks pixelated when it's presented. I tried it with a larger image, it also go beyond the tab bar.
You've to provide images with the right dimensions. A Tabbar Icon has to be at least 25x25 pixels for a device with a standard resolution and at least 50x50 pixels for high resolution screens.
See the Apple developer library for further reference :
https://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/IconMatrix
When you're using images.xcassets in your project to manage your images you'll see multiple versions of a image when you import it. E.g.:
Left: 25x25 pixels right:50x50 pixels. When you don't provide images with the right dimensions in your imageset, the compiler will give you a warning.

Retina , non retina images, showing white background

I have an app where the designer has given me assets or png's in two formats, non retin and retina,well formatted and named with #2 properly.
the retina images work fine, but the non retina images show a weird white background behind them. anyone ever experience this?
Here in those two images, they are both showing against a black uiview, when running retina the arrow fills with a black background, but for non retina devices its a white background.
I don't think it's the problem, but from your question it look like you forgot #2x in the name of your image.
For non-retina display the correct name is youImage.png and for retina youImage#2x.png
Check your youImage.png in photoshop (for example) and check if the background is not part of the image itself. It append to me more than one...
Edit:
Since you added the two picture in your post, I can confirm:
Your non-retina picture (the small on) got white background embedded. Ask your designer to remove it and use a transparent background.
Edit2:
Try with this picture as non-retina image. I removed the background for you (quick and durty just to test)
=====>
Edit3:
I edited your image and set a red background. Now you can clearly see that your non-retina image embed a background.

Do you have to specify the resolution of images for the Native tab bar with TriggerIO

TriggerIO supports the native tab bar and it looks really easy to add buttons but does it support retina graphics for the icons? Or is this needed? (specifying the nicer image scales down? )
A single, larger image is the best option - we do scale them down to fit properly inside the button itself.
As a rule of thumb, the icon should be > 100 pixels high to stay crisp on retina displays.
I've tried using icons that are 100x100 and 200x200, and they all look fuzzy and pixelated on iPhones with Retina display. Looks like they are resized for non-retina devices only.

How big should a UIBarButtonItem image be?

I'm looking to create my own custom Sort By Date and Sort By Number buttons that I plan on placing in the navigation bar as the right button.
How big should my image be to appropriately fill the space -- the UIBarItem documentation page doesn't list anything about the size the image should be.
As of iOS 11, the Human Interface Guidelines suggest glyphs be about 25×25 points in toolbars and navigation bars, up to a maximum of about 28 points. (And the HIG should definitely be in your bookmarks if you're working on iOS apps!)
That would translate to images 25px square for older devices like iPad 2 / Mini, 50px square for most current devices like iPhone 8 or iPad, and 75px square for Retina HD devices (the iPhone 6/7/8 Plus, or iPhone X). Asset catalogs will help immensely in keeping the different asset sizes organized (and Xcode can even generate them from vector sources these days).
The Human Interface Guidelines tells you this since iOS7:
Regardless of the icon’s visual style, create a toolbar or navigation
bar icon in the following sizes:
About 44 x 44 pixels
About 22 x 22 pixels (standard resolution)
Here is a great matrix of all needed sizes for resources for all platforms
Yes, Apple suggest to use images with 22px, 44px and 66px size for UIBarButtonItems, but if you use preinstalled icons like Bookmark icon, it's sized by 25px 50px and 75px for 1x, 2x and 3x respectively.
Here are 2 icons in UIToolbar. On the right is Apple's system bookmark icon and on the left my custom icon.
Here my custom icon sized 22px-44px-66px:
And here 25px-50px-75px:
So, if you use custom and system icons in one toolbar, I would suggest to use 25px-50px-75px scaling, or your custom icons will be smaller. In fact I always use 25px-50px-75px scaling, it looks better on toolbars, as for me.
Easy: Include your images in Assets.xcassets.
How?
Clic on Assets.xcassets
Clic + icon and then click "New Image Set"
Drag and drop your image to 3x slot
Rename the image set
In the BarButton you can use this name under "Image" field

Resources