views:

139

answers:

4

Hi all,

Further to this question here, I'm really interested in creating my own UITabBar, and 'rolling my own'. Im really curious as to how this is done, especially in an app such as the Twitter app.

How can I do this? Can anyone point to any good resources on how to subclass this? Should I do it programmatically, or in a XIB?

Edit: I'm looking to do this with custom icons/selected icons and having icons only. Edit2: After reading further answers, it sounds like a custom XXTabBarcontroller is what I actually want to do here. Can anyone comment on this?

Thank you,

+4  A: 

I don't know if there is a best way to do this, but I will share my experience:

I created my own version of a tab bar by subclassing UIView as opposed to UITabBar. As the linked question mentions, Apple's UI classes are quite finicky about their sizing and I do not think I could get the UITabBar subclass to size as I wanted.

Because I did not have a subclass of UITabBar I also ended up rolling my own versions of UITabBarController and UITabBarDelegate, with interfaces that are essentially the same as the Apple classes. I WAS able to use UITabBarItem to store the title and icon for the buttons on the tab bar, which is useful since UIViewControllers have a tabBarItem property. That lets you store just an array of UIViewControllers in your controller, as opposed to arrays for both controllers and tab bar items.

Because I was using mostly custom classes I did this all programmatically, including creating, configuring and laying out the buttons on the tab bar.

Like I said, this is just my experience, hope it helps.

Tim Isganitis
Thanks Tim. Do you have any code you could share to demonstrate this?
barfoon
Unfortunately, my tab bar and associated controller have a bunch of custom behavior I'd have to factor out to post the whole thing as an example. I don't have time to do that right now, but if you have specific questions about the implementation I'm happy to share snippets of code.
Tim Isganitis