Pages

Sunday, June 5, 2011

To change the default color of the Tab-Bar


Add the below code in viewWillAppear of your class
CGRect frame =
CGRectMake(0.0, 0.0,self.view.bounds.size.width, 48);
UIView *v = [[UIView alloc] initWithFrame:frame];
[v setBackgroundColor:[UIColor colorWithRed:0.1 green:0.2 blue:0.6 alpha:0.8]];
[v setAlpha:0.5];
[[self.tabBarController tabBar] insertSubview:v atIndex:0];
[v release];

And we can also image pattern color.
 UIImage *i = [UIImage imageNamed:@"abc.png"];
 UIColor *c = [[UIColor alloc] initWithPatternImage:i];

And we can also place image in tabbar background.
CGRect frame =
CGRectMake(0.0, 0.0,self.view.bounds.size.width, 48);
UIImageView *v = [[UIImageView alloc] initWithFrame:frame];
[v setImage:[UIImage imageNamed:@”YOUR IMAGE NAME”]];
[v setAlpha:0.5];
[[self.tabBarController tabBar] insertSubview:v atIndex:0];
[v release];

No comments:

Post a Comment