I have a tabbed application project I am working on in Xcode written in Swift (Xcode 6.3 and Swift 1.2
). I am having a lot of trouble with custom Tab Bar icons. I have designed an image in Photoshop (CS6), saved it as a PNG, resized it in Prepo to be 30x30
and imported it into Xcode in the asset library. I then set the tab view controllers
icon to that image. However, it doesn’t show up.
I have looked at these pages but not found any help:
https://www.youtube.com/watch?v=4qqqoAWNfZA
Custom tab bar icon colors
http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=19333
http://www.appcoda.com/ios-programming-how-to-customize-tab-bar-background-appearance/
https://www.youtube.com/watch?v=4Tj_SeApUrs
What is the proper process to create custom tab bar icons?
4
Answers
After a bit of research I resolved the issue, so thought I'd post here in case anyone else has a similar issue. In Photoshop I did the following:
75x75 pixels
(and named[email protected]
),50x50 pixels
(and named[email protected]
), and25x25 pixels
(and namedimageName.png
)In Xcode I did the following:
icoImageName
.icoImageName
. Note that I did not set the 'Selected Image' under the 'Tab Bar Item' (leave this blank).Done.
I hope this helps someone. Thanks to everyone for their help as well.
Did you create the tab view in interface builder? If so, since you added the images as an asset they should show up in the ‘Image’ property of each tab button under the inspector sidebar. Also, I know you’ve already posted a ton of tutorials, but this one is pretty up to date and explains it thoroughly: http://codewithchris.com/ios-tab-bar-app/
It sounds like you have everything set up properly in xCode. The problem IS the png file you are using.
Download this image, http://i.stack.imgur.com/zluev.png , and see if the problem persists.
According to an answer on UITabBarItem images just appear as a grey block: