When you are creating a tab bar for your own application, you face the problem of providing the icons. You have several options here.
Your first option is to use one of Apple's system icons. Like the navigation bar, you have access to some of Apple's system icons, and they even encourage you to use them. Unfortunately, there are a couple caveats with using these. First, the list is pretty skimpy. Second, the icons include the text as well. You cannot set the image and the text separately; it's both or nothing. Here is what is offered:
icon | text | enum |
More | UITabBarSystemItemMore | |
Favorites | UITabBarSystemItemFavorites | |
Featured | UITabBarSystemItemFeatured | |
Top 25 | UITabBarSystemItemTopRated | |
Recent | UITabBarSystemItemRecents | |
Contacts | UITabBarSystemItemContacts | |
History | UITabBarSystemItemHistory | |
Bookmarks | UITabBarSystemItemBookmarks | |
Search | UITabBarSystemItemSearch | |
Updates | UITabBarSystemItemDownloads | |
Most Recent | UITabBarSystemItemMostRecent | |
Most Viewed | UITabBarSystemItemMostViewed |
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:0];
You execute this in your UIViewController subclass that you are putting into the tab bar. This is best done in your view controller's initializer method:
- (id) init
{
self.title = "search";
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:0];
return self;
}
If the system icons don't meet your needs, some people have suggested doing a screen capture of an app that has an icon you like. Ignoring the legalities of this, this may not give you good results because Cocoa-Touch has already applied affects to the icons.
Your next option would be to search for some free or pay-for icons. I noticed many freelance graphics designers putting their shingle up and offering their services. I didn't look long, but I did not find any suitable, free icons for iPhone tab bars.
This leaves you one last option: create your own. So the first questions that come up are:
- what format?
- what size?
- what colors?
If this image is too large to fit on the tab bar, it is scaled to fit. The size of an [sic] tab bar image is typically 30 x 30 points.Note it doesn't say what the max size is before it gets scaled. One poster thought the max size was around 48 x 32 before scaling happens. But if Apple doesn't publish this information explicitly, I would hesitate to use it. You could explore yourself to find out what the max is, but obviously Apple would like to retain some latitude in this area to possibly change it in future firmware releases. I believe 30 x 30 is a safe size that will give you the best look. There also seems to be a great deal of confusion regarding colors. From my research, colors are basically ignored. Here is what the Apple document "View Controller Programming" has to say about it:
The unselected and selected images displayed by the tab bar are derived from the images that you set. The alpha values in the source image are used to create the other images—opaque values are ignored.In other words, Cocoa Touch will create new images from your source images, using alpha values only. Alpha, in the PNG world, is the degree of a pixel's opacity. Maximum alpha values denote a completely opaque pixels. In the example below this quoted text, they have an example source image and the resulting unselected and selected icons. Color is irrelevant. In part 2 of this article, I will discuss various tools used to compose icons, specifically how to create tab bar icons.
THanks for the post.
ReplyDeleteUseful, thanks. =)
ReplyDelete30x30 is definitely smaller than the default icon size, at least when there are only four items. I used the 48x32 suggestion that you mentioned, and that seemed to be perfect.
ReplyDeleteThanks for this great post!
dude you are god! :) keep the hard work!
ReplyDeleteI found some good icons to use on http://glyphish.com/!!!
ReplyDeleteWe use them in PerTrainer iPhone application http://pertrainer.com
You can see screenshots here:
http://pertrainer.com/Home/InfoForIPhoneUsers
I also found some good icons here:
http://www.app-bits.com/downloads/iphone-toolbar-icon-set.html
Happy developing.
Also check out this icon set: 270 Toolbar Icons for iPhone 4 @2x Retina Display / 30 are free, 270 are $20.
ReplyDeletehttp://www.billybarker.net/iphone-4-retina-icons-for-app-developers/
Worked like a charm :) Nice going
ReplyDeleteHere is a lot of tab bar icons http://www.aha-soft.com/iconsets.htm#ios
ReplyDeleteThanks.
ReplyDeleteAnd look for free mobile icons :
http://www.pixelledesigns.com/free-mobile-app-icons.htm
http://www.iconbeast.com (One of the best iOS tab bar and toolbar icons out there)
ReplyDelete