There seems to be a lot of different ways to change the appearance of a UITabBar. I found that in iOS 5, there are new properties of the UITabBar such as backgroundImage
. However, how and where do I set this?
I would like to subclass UITabBar and override the initWithFrame
method, setting the background image.
Although I have created a new class @interface UITabBarClass : UITabBar
and in the implementation of initWithFrame
added the following code:
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code
// Change background image
UIImage *backgroundImage = [UIImage imageWithContentsOfFile:@"uitabbar-background-normal"];
self.backgroundImage = backgroundImage;
}
return self;
}
the background image does not change. I have also tried writing a log in the same method and it does not get logged at run time.
Can anyone help or give advice?
Thanks in advance! :)
I fixed this by following this tutorial, please note that you do not need to create 'tabBar1' as it says, just use self.tabBar
: http://www.jondack.com/index.php/2010/12/16/customizing-the-background-of-a-uitabbarcontroller/