0

I'm using Xamarin Forms Shell TabBar and i'm working into renderers to customize this tabbar, i want to change icon when a tab is selected.

I found this tutorial : https://montemagno.com/tintcolor-selectedimage-xamarin-forms-ios/

I'm trying to achieve the "Selected TabItem Image" part where i have for each tab an icon for selected state and an icon for unselected state.

My issue is this tutorial using classic TabbedPage renderer where i am using a IShellTabBarAppearanceTracker (because i am using shell) and i can't access the tabs.Children[i].Icon property, only the controller.TabBar in public void SetAppearance(UITabBarController controller, ShellAppearance appearance) method.

So i have no way to access current tab icon's name to perform the following code :

icon = icon.Replace(".png", "_selected.png");
if(item?.SelectedImage?.AccessibilityIdentifier == icon)
    return;
item.SelectedImage = UIImage.FromBundle(icon);
item.SelectedImage.AccessibilityIdentifier = icon;

is there a way to do it ? Or do we have to do it differently ?

ArthurCPPCLI
  • 1,072
  • 7
  • 18
  • 1
    I was looking for this also, feature request that may make this easier https://github.com/xamarin/Xamarin.Forms/issues/14056 – Cfun Mar 31 '21 at 09:26
  • 1
    I think this https://stackoverflow.com/questions/58635349/xamarin-forms-shell-custom-icon-for-selected-tab is the same question and has a correct answer... – Depechie Mar 31 '21 at 12:23
  • Thanks for pointing that out i didn't see it before, agree it is the same question. I know it is possible with custom renderer but personally i am looking for a more elegant approach (avoid custom renderer and avoid hard coding to specific case) to be more flexible like vsm. – Cfun Mar 31 '21 at 12:28
  • 2
    Does this answer your question? [Xamarin forms Shell Custom icon for selected tab](https://stackoverflow.com/questions/58635349/xamarin-forms-shell-custom-icon-for-selected-tab) – Cfun Mar 31 '21 at 12:31

0 Answers0