UITabBar

Discussion in 'iOS Programming' started by Nnavick, Apr 12, 2011.

  1. macrumors regular

    Joined:
    Oct 13, 2010
    #1
    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
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    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.
     
  3. thread starter macrumors regular

    Joined:
    Oct 13, 2010
    #3
    What do you mean ?

    Thanks!
     
  4. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Meaning: UITabBar is a subclass of UIView. Therefore, you can add your own subviews.

    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 is a customized UISwitch but rather than subclassing UISwitch and extending it, they actually subclassed UIView.
     
  5. thread starter macrumors regular

    Joined:
    Oct 13, 2010
    #5
    [self.tabBarController addSubview:myimage];

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

    what should I do?
     
  6. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    Do you understand the difference between UITabBarController and UITabBar?
     
  7. Nnavick, Apr 12, 2011
    Last edited by a moderator: Apr 12, 2011

    thread starter macrumors regular

    Joined:
    Oct 13, 2010
    #7
    I tied both and it's gave the same warning

    EDIT:

    Figured it out

    thank you
     
  8. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    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 and especially the kinder, gentler Getting Answers.
     

Share This Page