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.
Try to override the ViewWillAppear
event in your custom renderer of the tabbed page. TintColor
of the Tabbar could change the selected item's color and UnselectedItemTintColor
could be used to change the unselected items':
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); TabBar.TintColor = UIColor.Orange; TabBar.UnselectedItemTintColor = UIColor.White; }
Besides, UnselectedItemTintColor
is available after iOS 10.
Answers
Try to override the
ViewWillAppear
event in your custom renderer of the tabbed page.TintColor
of the Tabbar could change the selected item's color andUnselectedItemTintColor
could be used to change the unselected items':Besides,
UnselectedItemTintColor
is available after iOS 10.Thank you @LandLu by adding this lines working for me
but i am unable to remove bottom bar text is there any way to do ?
Thanks,
Jagdeesh.