As I said elsewhere, it is almost never a good idea to get rid of the basic navigation classes provided by UIKit . What are your requirements for applications that you think deserve a fully customizable tab bar class? You can almost always achieve the necessary settings by subclassing, categorizing, or using layers.
UPDATE 1 . So, here is what I did in some of my applications to create a custom tab bar.
- Subclass
UITabBar - Add a method to your subclass called
-updateTabBarImageForViewControllerIndex: - In the Builder interface, change the tab bar class of the tab bar to your own subclass
- In any class that matches the tab bar delegate delegate (for example, the application delegate), implement
-tabBarController:shouldSelectViewController: and call -updateTabBarImageForViewControllerIndex: in your sub-tab tab bar
Basically, you want to notify your tab bar subclass every time a tab bar controller is about to switch view controllers. When this happens, determine which image to select for the tab bar. You must have n images for your tab bar, one for the selected state of each tab. This allows you to actually clean up the UITabBarItem implementation and just work with individual images, but it works a bit more.
UPDATE 2 . Now that I think about it more, you could (and should) get away from what you are trying to achieve without a subclass of UITabBar at all. Import <QuartzCore/QuartzCore.h> and use the contents of the layer. :)
source share