Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to change bottom navigation bar icon color Xamarin forms ios

jagdeeshkjagdeeshk Member ✭✭

In my project i added bottom navigation bar but i facing an issue unable to change default icon selection colors.

Tabbed page renderer written like this

protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
    base.OnElementChanged(e);
    UITextAttributes normalTextAttributes = new UITextAttributes();
    normalTextAttributes.Font = UIFont.FromName("SanFranciscoText-Light", 9.0F); // unselected

    TabBar.TintColor = UIKit.UIColor.FromRGB(153, 67, 2);
    TabBar.BarTintColor = UIColor.FromRGB(223, 139, 75); 
    try
    {
        var tabbarController = (UITabBarController)this.ViewController;
        if (null != tabbarController)
        {
            tabbarController.ViewControllerSelected += OnTabbarControllerItemSelected;
        }
    }
    catch (Exception exception)
    {
        Console.WriteLine(exception);
    }
    UITabBarItem.Appearance.SetTitleTextAttributes(normalTextAttributes, UIControlState.Normal);
}


public override UIViewController SelectedViewCont
{
    get
    {
        UITextAttributes selectedTextAttributes = new UITextAttributes();
        selectedTextAttributes.Font = UIFont.FromName("SanFranciscoText-Bold ", 12.0F); // SELECTED
        selectedTextAttributes.TextColor = UIColor.White;
        return base.SelectedViewController;
    }
    set
    {
        allViewControllers = base.ViewControllers.ToList();
        base.SelectedViewController = value;
        foreach (UIViewController viewController in base.ViewControllers)
        {
            UITextAttributes normalTextAttributes = new UITextAttributes();
            normalTextAttributes.Font = UIFont.FromName("SanFranciscoText-Light ", 9.0F); 
            viewController.TabBarItem.SetTitleTextAttributes(normalTextAttributes, UIControlState.Normal);
        }           
    }
}

I want to change selected tab Icon color to dark orange and unselected tab color to white. Is there any way to do this ?

Thanks,
Jagdeesh.

Best Answer

Answers

  • jagdeeshkjagdeeshk Member ✭✭
    edited June 26

    Thank you @LandLu by adding this lines working for me

    TabBar.SelectedImageTintColor = UIColor.Red;
    TabBar.UnselectedItemTintColor = UIColor.White;
    

    but i am unable to remove bottom bar text is there any way to do ?

    Thanks,
    Jagdeesh.

Sign In or Register to comment.