1

I'm using the following code in 'viewDidLoad' of the various view controllers of my tabbed app.

    UIColor *tabBarColor = [UIColor colorWithRed:85.1 green:57.6 blue:71.4 alpha:.5];
    [[UITabBar appearance] setTintColor:tabBarColor];

But the image that I get, which ought to be pink, is this:

enter image description here

I can make it lighter or darker by changing the alpha, but never colored--only black/white/gray.

Any thoughts about how I can solve this problem?

Joel Derfner
  • 2,167
  • 4
  • 30
  • 44

4 Answers4

5

Under header files in .m write this line #define RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1] now where you are setting color put this code for pink color [[UITabBar appearance] setTintColor:RGB(255, 192, 203)]; that's all

frank nirania
  • 300
  • 1
  • 6
1

Try this:

   if ([tabBarController.tabBar respondsToSelector:@selector(setTintColor:)]) 
    {
        [tabBarController.tabBar setTintColor: tabBarColor];
    }
V-Xtreme
  • 6,775
  • 6
  • 33
  • 76
1

Colors must come with decimal point after the number: 215.0/255. Because it's float.
If you want to be precise with floats and doubles on 32bit and 64bit systems you also should add f after the number: 215.0f/255. The compiler will know it's 32bit. Now your problem is you didn't write the divide mark: N_OF_COLORS / TOTAL_COLORS.

pbibergal
  • 2,901
  • 1
  • 15
  • 19
0

UIColor *tabBarColor = [UIColor colorWithRed:85.1 green:57.6 blue:71.4 alpha:.5]

Colors must come with decimal point after the number: 215.0/255. Because it's float.

try this:

UIColor *tabBarColor = [UIColor colorWithRed:(87/255.0) green:(153/255.0) blue:(165/255.0) alpha:1];


[[UITabBar appearance] setTintColor:tabBarColor];
Ravindhiran
  • 4,974
  • 7
  • 46
  • 79