PDA

View Full Version : UITabBar




Nnavick
Apr 12, 2011, 08:01 AM
Hi'
I want to add an color image to my tab bar but when I'm adding my image it's turn to gray and put it over the title even the title is "".

how can I add a color image to the tab bar and make it all over the tab?

Thank you



dejo
Apr 12, 2011, 10:01 AM
UITabBarItem's image cannot contain color (in fact, as the doc states, "The alpha values in the source image are used to create the unselected and selected images"). You may be able to hack in your own subviews or you'll have to roll your own tab bar.

Nnavick
Apr 12, 2011, 01:26 PM
What do you mean ?

You may be able to hack in your own subviews or you'll have to roll your own tab bar.

Thanks!

dejo
Apr 12, 2011, 01:45 PM
You may be able to hack in your own subview...
Meaning: UITabBar is a subclass of UIView. Therefore, you can add your own subviews.

...or you'll have to roll your own tab bar.
Meaning: You might be able to subclass UITabBar and customize it to meet your specific needs or you could create a whole new custom class that operates similar to a UITabBar but created by you from scratch. For example, RCSwitch (http://osiris.laya.com/projects/rcswitch/) is a customized UISwitch but rather than subclassing UISwitch and extending it, they actually subclassed UIView.

Nnavick
Apr 12, 2011, 02:20 PM
[self.tabBarController addSubview:myimage];

: Semantic Issue: 'UITabBarController' may not respond to 'addSubview:'

what should I do?

dejo
Apr 12, 2011, 02:25 PM
[self.tabBarController addSubview:myimage];

: Semantic Issue: 'UITabBarController' may not respond to 'addSubview:'

what should I do?
Do you understand the difference between UITabBarController and UITabBar?

Nnavick
Apr 12, 2011, 02:42 PM
I tied both and it's gave the same warning

EDIT:

Figured it out

thank you

dejo
Apr 12, 2011, 03:08 PM
I tied both and it's gave the same warning
Tried both? You've only posted one attempted solution. Please don't expect us to guess what the other one was. If you haven't already, I'd suggest reading through What Have You Tried (http://whathaveyoutried.com) and especially the kinder, gentler Getting Answers (http://www.mikeash.com/getting_answers.html).