Way to override the tabbar more menu

Jon 1 Reputation point
2021-03-18T16:53:08.01+00:00

I was wondering how I would go about changing the "more" menu on a tabbar on iOS to be a bottom pop up rather than a full page.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-03-19T07:16:51.73+00:00

    Hello,

    Welcome to Microsoft Q&A!

    If I understand correctly , do you want to show a pop up rather than a full page when clicking on the more button on tabbar ?

    If so , you can achieve it with custom renderer in iOS project .

       [assembly: ExportRenderer(typeof(TabbedPage), typeof(MyTabRenderer))]  
       namespace FormsA.iOS  
       {  
           public class MyTabRenderer : TabbedRenderer  
           {  
               public override void ViewDidLoad()  
               {  
                   base.ViewDidLoad();  
                   this.ViewControllerSelected += MyTabRenderer_ViewControllerSelected;  
    
               }  
    
               UIViewController lastViewController;  
    
               private void MyTabRenderer_ViewControllerSelected(object sender, UITabBarSelectionEventArgs e)  
               {  
                   var index = this.ViewControllers.ToList().IndexOf(e.ViewController);  
    
                   if(index == -1)  
                   {  
                       //handle stuffs  
    
                       this.SelectedViewController = (lastViewController!=null)? lastViewController: this.ViewControllers[0];  
                   }  
    
                   lastViewController = e.ViewController;  
               }  
           }  
       }  
    

    Update

    If you're using shell project ,check the code below

       [assembly: ExportRenderer(typeof(Xaminals.AppShell), typeof(Xaminals.iOS.MyShellRenderer))]  
       namespace Xaminals.iOS  
       {  
           public class MyShellRenderer : ShellRenderer  
           {  
               protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()  
               {  
                   return new TabBarAppearance();  
               }  
           }  
    
           public class TabBarAppearance : IShellTabBarAppearanceTracker  
           {  
               public void Dispose()  
               {  
    
               }  
    
               public void ResetAppearance(UITabBarController controller)  
               {  
    
               }  
    
               bool isFirst = true;  
               UIViewController lastViewController;  
               public void SetAppearance(UITabBarController controller, ShellAppearance appearance)  
               {  
    
                   if(isFirst)  
                   {  
                       controller.ViewControllerSelected += (sender, e) =>  
                       {  
                           var index = controller.ViewControllers.ToList().IndexOf(e.ViewController);  
    
                           if (index == -1)  
                           {  
                               //handle stuffs  
                               controller.SelectedViewController = (lastViewController != null) ? lastViewController : controller.ViewControllers[0];  
                           }  
                           else  
                           {  
                               lastViewController = e.ViewController;  
                           }               
                       };  
                       isFirst = false;  
                   }           
               }  
    
               public void UpdateLayout(UITabBarController controller)  
               {  
    
               }  
           }  
       }  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    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.