• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Change background color of UITabBarItem and UITabBar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Change background color of UITabBarItem and UITabBar


  • Subject: Re: Change background color of UITabBarItem and UITabBar
  • From: Greg Reichow <email@hidden>
  • Date: Wed, 27 Jan 2010 21:01:00 +0800

>
> Thanks for this information. It did change the color of the TabBar.
> But the other question is still unanswered. Is it possible to change
> the TabBarItem's image colors? Instead of default gray (when not selected)
> and blue (when selected)? How?
>
Again, a little bit of a grey area as you are overriding private methods.  So, this very well could break in future updates.  Be warned.  But here is an example for your understanding-

Subclass  UITabBarItem and override the private method selectedImage.

@interface GRCustomUITabBarItem : UITabBarItem
{
	UIImage		*customHighlightedImage;
}

@property (nonatomic, retain) UIImage *customHighlightedImage;

@end

@implementation GRCustomUITabBarItem

@synthesize customHighlightedImage;

- (void) dealloc
{
	[customHighlightedImage release]; customHighlightedImage=nil;
	[super dealloc];
}

-(UIImage *) selectedImage
{
	return self.customHighlightedImage;
}

@end

Then in the init of each one of the viewControllers that corresponds to a tab, you setup the tabBarItem

// Customized Tab Bar Item

		GRCustomUITabBarItem *tabItem = [[GRCustomUITabBarItem alloc] initWithTitle:@"Home" image:[UIImage imageNamed:@"home.png"] tag:0];
		tabItem.customHighlightedImage=[UIImage imageNamed:@"Home-sel.png"];
		self.tabBarItem=tabItem;
		[tabItem release]; tabItem=nil;

The customHighlightedImage should be a png properly sized and colored as you like.  It will be used as-is and not recolored to the blue like normal.

Greg
MangoCode

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Change background color of UITabBarItem and UITabBar (From: Angelica Grace Tanchico <email@hidden>)

  • Prev by Date: Re: How to access iTunes using cocoa
  • Next by Date: Localization help
  • Previous by thread: Re: Change background color of UITabBarItem and UITabBar
  • Next by thread: How to access iTunes using cocoa
  • Index(es):
    • Date
    • Thread