2

I disabled tabBar item then bar button became grey .

I want to change its color but could not do.its by default grey.

When I setEnabled true then its showing original color white.

[[[[self.tabBarController tabBar]items]objectAtIndex:0]setEnabled:FALSE];
Andrey Korneyev
  • 26,353
  • 15
  • 70
  • 71
  • possible duplicate of [How can I change the text and icon colors for tabBarItems in iOS 7?](http://stackoverflow.com/questions/18734794/how-can-i-change-the-text-and-icon-colors-for-tabbaritems-in-ios-7) – Yuri Solodkin Jun 02 '15 at 11:15

2 Answers2

1

I have used this in appDelegate it works fine for me.

 [[UIView appearanceWhenContainedIn:[UITabBar class], nil] setTintColor:[UIColor whiteColor]];

 [[UITabBar appearance] setTintColor:[UIColor whiteColor]];

but when i set enable False in viewController class then it will become grey.

ChenYilong
  • 8,543
  • 9
  • 56
  • 84
Sonu Singh Jadoun
  • 245
  • 1
  • 3
  • 17
0
  // this will generate a red tab bar
    tabBarController.tabBar.barTintColor = [UIColor redColor];

    // this will give selected icons and text your apps tint color
    tabBarController.tabBar.tintColor = [UIColor redColor];

Update :

self.tabBarController.tabBar.barTintColor = [UIColor blackColor];
self.tabBarController.tabBar.translucent = false;
self.tabBarController.tabBar.tintColor = [UIColor blueColor];
Omarj
  • 1,151
  • 2
  • 16
  • 43
  • but when i use self.tabBarController.tabBar.tintColor = [UIColor whiteColor]; self.tabBarController.tabBar.barTintColor = [UIColor whiteColor]; it look grey after setEnabled False TabBarItem . – Archit rai saxena Jun 02 '15 at 13:15
  • 1
    I would like to disable the currently selected TabBarItem to prevent the user from taping on the same item again . To do that, I disable the currently selected TabBar Item. [[[[self.tabBarController tabBar]items]objectAtIndex:currentIndex]setEnabled:FALSE]; My problem is that when I disable the item. It becomes partially dimmed. So the Item is selected and its enabled property is set to FALSE. Under these conditions, the dimmers (due to the setEnable:FALSE) "wins" and the TabBarItem image dimmed down instead of highlighted.s there a way to prevent the dimmed effect ? – Archit rai saxena Jun 02 '15 at 13:33
  • omg u don;t need to disable it , all what u need is when user hit the button again check if user already load this view or set flag userhitMidTap= yes and don;t run your code if yes – Omarj Jun 02 '15 at 13:35
  • i could not set tag and call delegates, because there are two screens will be open conditionally so i have to disable first tab bar item – Archit rai saxena Jun 03 '15 at 13:32