How to hide Tab Bar on push in Xamarin.Forms?

前端 未结 4 1151
野性不改
野性不改 2021-01-14 16:04

I\'m struggling for last few days with TabbedPage in Xamarin.Forms on iOS. I found some solutions like those: https://forums.xamarin.com/discussion/20901/hide-t

4条回答
  •  被撕碎了的回忆
    2021-01-14 16:16

    What I have tried :

    • Create subclass of ContentPage and create BindableProperty(like HidesBottomBarWhenPushed) inside it. I set ViewController.hidesBottomBarWhenPushed in PageRenderer but it doesn't work, although I can get the value of this property .

    • set this.hidesBottomBarWhenPushed in the initial constructor in PageRenderer , still no luck.

    I think it must be something wrong with hidesBottomBarWhenPushed , we can not hide tabbar by this way. As a temporary and simple workaround , I change the Visible of TabBarController.TabBar in PageRenderer

    class PageiOS : PageRenderer
    {
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            if (this.NavigationController != null && this.TabBarController != null)
            {
                bool isRootVC = this.NavigationController.ViewControllers.Length == 1;
                ParentViewController.TabBarController.TabBar.Hidden = !isRootVC;
            }
        }
    }
    

    It behaves like what you said above , there is some delay and blank space on the bottom . I disable the animation on the push and pop , and the issue disappeared.

    Test:

提交回复
热议问题