How can I decrease the size of a UI Tab Bar Item Image so that it fits inside the Tab bar?

TW80000 picture TW80000 · Apr 17, 2015 · Viewed 12.1k times · Source

This is for a tab bar for an iPhone app, using the Swift coding language in Xcode 6.3

My issue is that I want to add an image into my Tab bar in one of my view controllers, but the image is too large. My original solution to this was to manually decrease the size of the image using preview, but the resolution was poor after doing that. Is there a line of code that I can put into the app delegate that could resize an image without changing the source file? Does anyone know of any other way to solve this problem?

The picture of the manually sized, low resolution image

The picture of the original, full resolution image, that is oversized

The second image is the goal, but without the resolution loss.

Answer

Swapnil Luktuke picture Swapnil Luktuke · Apr 17, 2015

This is not possible.

Check Icon and Image Sizes guidelines from apple. It categorically mentions:

Unlike other custom artwork in your app, the icons and images listed in Table 41-1 must meet specific criteria so that iOS can display them properly.

This applies to the tab bar icons too. So, if your images are larger than the max size (mentioned in above link), you will face such issues. Better resize the images.

If you are worried about poor resolution on retina displays (6, 6+ etc), make sure you provide @2x and @3x images for each tab bar image to Support the Retina display.