iOS barTintColor is always lighter than the color that is defined RRS feed

  • Question

  • User4024 posted

    I have this color "#31608c", On forms I set the action bar with this color and seems fine,

    but when i manually decompose it to RGB (49,96,140) and set the BarTintColor on iOS platform it always seems lighter than the color from the action bar.

    any ideas? Im not even converting by code anymore, im just typing the colors directly into the parameter.

                // 31608c   -> (49,96,140)
                UITabBar.Appearance.BackgroundColor = UIColor.FromRGB(49, 96, 140);
                UITabBar.Appearance.TintColor = UIColor.FromRGB(49, 96, 140);
                // UITabBar.Appearance.BarTintColor = UIColor.FromRGB(r, g, b);
                UITabBar.Appearance.BarTintColor =  UIColor.FromRGB(49-10, 96-10, 140-10);
                Debug.WriteLine("Tint->" + r + " " + g + " " + b);
                UITabBar.Appearance.SelectedImageTintColor = UIColor.White;
    Thursday, October 9, 2014 1:54 PM

All replies

  • User181 posted

    What is under the bar? Bars in iOS 7+ are typically semi-translucent so if you have a light color underneath then it effectively brightens the color. Try setting Translucent to false. I'm not sure you can do that using the Appearance API, though.

    Thursday, October 9, 2014 2:41 PM
  • User4024 posted

    I was searching to get my UITabBar opaque or set translucent to false, but doesn't seem to have any property on it

    Thursday, October 9, 2014 2:54 PM
  • User181 posted

    It's this one: http://api.xamarin.com/?link=P%3aMonoTouch.UIKit.UITabBar.Translucent

    Thursday, October 9, 2014 3:06 PM
  • User4024 posted

    Yes but I dont seem to be able to access it by

    UITabBar.Translucent or UITabBar.Appearance.Translucent or setTranslucent or isTranslucent

    Thursday, October 9, 2014 4:44 PM
  • User181 posted

    It's an instance property, not a static. It's also available since iOS 7 so make sure you are using a a newer SDK.

    Thursday, October 9, 2014 5:23 PM
  • User4024 posted

    Sorry for the persistence in this issue but i'm a bit lost here. Im trying to set this property for all the tabs in the app.

    my colleague told me he used the UITabBar properties to affect the whole application like shown in the code above.

    This is done in a Xamarin.Froms.Dependency.

    So if these Opaque and translucent properties are only accessible by instance I would have to create my own UITabBar and replace the current one. But at same time the UITabBar used above doesn't contain Appearance, so I'll need to use both.

    I can't understand on how are "these two" connected? the static and the instance.

    I also cannot get the child elements and set the property in all of them because its "abstract".

    I also thought on creating a renderer for the control but all i could find was a TabbedRenderer which doesnt seems to be the same thing(?)

    Thursday, October 9, 2014 6:18 PM
  • User181 posted

    This property isn't supported by the UIAppearance API (blame Apple). You will need a custom renderer.

    Thursday, October 9, 2014 6:27 PM
  • User75538 posted

    Hi @JOAO, try this:

    UITabBar.Appearance.BackgroundColor = UIColor.FromRGB(49.0/255.0, 96.0/255.0, 140.0/255.0);

    My applications work fine with code above.

    Thursday, October 9, 2014 7:23 PM
  • User4024 posted

    @jefnazario thanks for the attempt but the colors are still not the same like adam said there seems to be operations being executed over the original color due all the translucent effects. The color is very similar but not the same.

    This also might not happen in all iOS versions.

    Friday, October 10, 2014 9:30 AM
  • User4024 posted

    Thanks for the support, making a renderer seemed to work

    [assembly: ExportRenderer(typeof(TabbedPage), typeof(CustomGenericTabbedPage))]
    namespace Glintths.MobileApps.iOS.Renderers
        public class CustomGenericTabbedPage : TabbedRenderer
            public CustomGenericTabbedPage ()
                TabBar.Translucent = false;
                TabBar.Opaque = true;
    Friday, October 10, 2014 10:24 AM
  • User73862 posted

    @JOAO? I had the same problem. To fix it do it like this:

    TabBar.BackgroundImage = new UIImage(); TabBar.BackgroundColor = UIColor.FromRGB(49, 96, 140);

    The thing is they overlay a "default" image over everything you put. So you just need to instantiate an empty one.

    Friday, October 10, 2014 10:25 AM
  • User366431 posted

    Thanks @JOAOSerra. Also @Teo's solution is working.

    Friday, March 30, 2018 8:38 AM