Share via

How do I implement CustomMoreNavigationControllerDelegate (to stylize the tabbed bar More menu) using ShellRenderer?

ryan willis 21 Reputation points
2022-06-29T17:51:08.647+00:00

Previously I was able to use the TabbedRenderer to customize the tab bar More menu as so...

public class ExtendedTabbedPageRenderer : TabbedRenderer  
{  
    protected override void OnElementChanged(VisualElementChangedEventArgs e)  
    {  
        base.OnElementChanged(e);  
  
        if (e.NewElement != null)  
        {   
            MoreNavigationController.Delegate = new CustomMoreNavigationControllerDelegate();  
        }  
    }  
}  

How do I do the equivalent with ShellRenderer (since there is no OnElementChanged override)? I'd like to use my existing CustomMoreNavigationControllerDelegate class (if possible) which contains all the styling logic

Developer technologies | .NET | Xamarin
0 comments No comments

Answer accepted by question author

Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,166 Reputation points Microsoft External Staff
2022-06-30T05:22:11.627+00:00

Hello,

If you want to stylize the tabbed bar more menu by using ShellRenderer, you could refer to the official documentation: Xamarin.Forms Shell custom renderers, and find the CreateTabBarAppearanceTracker on iOS platform.

There, we could use ShellRenderer to override this function to customize the Tabbar appearance. Here is a sample about modify the text of the more menu:

   public class MyShellRenderer : ShellRenderer  
   {  
       protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()  
       {  
           return new TabBarAppearance();  
       }  
   }  
     
   public class TabBarAppearance : IShellTabBarAppearanceTracker  
   {  
       //other methods were omitted  
       public void UpdateLayout(UITabBarController controller)  
       {  
           UITabBar tb = controller.MoreNavigationController.TabBarController.TabBar;  
           if (tb.Subviews.Length > 4)  
           {  
               UIView tbb = tb.Subviews[4];  
               UILabel label = (UILabel)tbb.Subviews[1];  
               label.Text = "CusMore";  
           }  
       }  
   }  

Best Regards,

Alec Liu.


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.