views:

955

answers:

0

I want to add a little flair to my application and while I have been somewhat successful, I haven't figured out a way to truly do what I want to do. I would try to subclass UITabViewController, but I don't think I would even know where to start or if that is the right approach.

Basically, what I want to do is have custom images for each tab bar button. I have both pressed and non-pressed images. Instead of using the highlight that is generated over the current icon, I want the pressed image to be shown. What I've been able to do is create a Category of the UITabBar with a custom drawRect method that basically draws all of my custom tab bar icons. I then initialize the same amount of UITabBarItems w/out specifying an image or title of any kind which I then add to the array of items. This lets me have my icons and then just overlays the highlight on them.

This is ok I guess, but I would really like to have the pressed button look.

Here is the code I use for drawing the tab bar:

@implementation UITabBar (CustomImage)


-(void)drawRect:(CGRect)rect
{
    UIImage *image = [UIImage imageNamed:@"TabBar.png"];
    [image drawInRect:CGRectMake(0,0,320,50)];
}

@end

And then I initialize the tab bar items like this:

UITabBarItem *homeTabBarItem = [[UITabBarItem alloc] init];

If anyone knows how I would do this, that would be greatly appreciated. Please keep in mind that I'm still relatively new to Objective-C, so I'm somewhat confused as to how I would correctly subclass anything at this point.

The functionality I'm looking for would be similar to what RougeSheep was able to accomplish with Postage: http://postage.roguesheep.com/ They did an awesome job, and this is kind of what I'd like to emulate.