Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

marcolara

macrumors newbie
Original poster
Aug 15, 2008
5
0
I looked all over the forum and googled without any success on this matter. I want to customize a UITabBar to display an image background instead of the dark gray background provided by the SDK. Is there a way for me to do this?

I tried creating a category for UITabBar and overwrite the drawRect method but this also has no effect since I don't even see in the debugger the UITabBar calling my method.

I'm doing most of it programmatically in my code and as far as I understand the UITabBar is directly attached to a UITabBarController, however the UITabBarItem objects are inside the UIViewController... is it possible that the change needs to happen in the UIViewController and not the UITabBar itself?

I've already spent over a day on this matter so it's time for me to ask the community for help so any suggestions, code snipped or comments will be highly appreciated.

Regards,
ML
 

marcolara

macrumors newbie
Original poster
Aug 15, 2008
5
0
have you tried subclassing it and implementing your own drawrect method that way?

Yes I did subclass the object, however, I really don't know how to implement it since the UITabBar is part of the UITabBarController itself. Is there a clear example as to how to use the UITabBar and add the ViewControllers to it without using the UITabBarController?

-ML
 

marcolara

macrumors newbie
Original poster
Aug 15, 2008
5
0
Problem solved!

I was able to get some help from a great developer. It was a simple implementation:

Code:
[[tabBarController tabBar] addSubview:view];

I'm passing an UIImageView as the view so I can get a customized background for my tab views.

--- Thanks Danielle C. for the tip! :)
 

jchildress

macrumors member
Jul 9, 2008
49
0
Is this background the size of the entire screen? or just a background for the tabBar at the bottom of the screen (360 x 40~ pixels)?

If the background is the entire screen, do you see it load immediatly as the app starts up? Or does it not appear until the tabBar's initial view is finished loading? Is the background always there, just drawn behind the current UIViewController?

Sorry for so many questions, but I think that you might be trying something that I've been trying to do for awhile now.
 

marcolara

macrumors newbie
Original poster
Aug 15, 2008
5
0
Is this background the size of the entire screen? or just a background for the tabBar at the bottom of the screen (360 x 40~ pixels)?

If the background is the entire screen, do you see it load immediatly as the app starts up? Or does it not appear until the tabBar's initial view is finished loading? Is the background always there, just drawn behind the current UIViewController?

Sorry for so many questions, but I think that you might be trying something that I've been trying to do for awhile now.

Nope. This is just to change/display an image behind the TabBar itself. The UIImageView is attached before the screen is rendered.
 

holtmann

macrumors newbie
Sep 24, 2008
10
0
This does not work for me:

1. [[tabBarController tabBar] addSubview:view]; - tabBar is an undefined method for an UIViewController
2. If I access the UITabBar through an IBOutlet set in InterfaceBuilder and do
then
[tabbar addSubView:myView] the View is added not as a background. The active item e.g. is still visible, but the inactive TabBarItems are invisible.

Any hints how to do this properly?

Best,

Hendrik

Nope. This is just to change/display an image behind the TabBar itself. The UIImageView is attached before the screen is rendered.
 

Isorinu'

macrumors newbie
Oct 16, 2008
19
0
can somebody give an example how to change the color of the UITabBar? or to put a background image?

I have a UITabBarController made programatically and i add ViewControllers to it..i tried the method mentioned above but it doesn;t work.. please help..i want to change the black color to lightGrayColor..
Thank you in advance
 

priyank.ranka

macrumors member
Jun 11, 2008
51
0
I also have the same issue i want to change dark gray to green... does anyone knows please do let me know...Many many thanx in advance
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.