Hiding TabBar on iOS 11 no longer working.

AndrewHoffmanAndrewHoffman USUniversity ✭✭

Prior to iOS 11, I was using this code inside a custom renderer for the TabPage to conditionally hide the TabBar in my app:

private void ToggleTabs(object sender, bool hideTabs)
{
    TabBar.Hidden = hideTabs;

    TabBar.Frame = TabBar.Hidden
        ? new CGRect(TabBar.Frame.X, TabBar.Frame.Y, TabBar.Frame.Width, 0)
        : new CGRect(TabBar.Frame.X, TabBar.Frame.Y, TabBar.Frame.Width, tabBarHeight);
}

where tabBarHeight is calculated when the TabBar is constructed (it should always be 49 according to the docs, but I hate magic numbers).

The problem that I'm now running into is that even though I'm collapsing the frame, there is still a white rectangle left where the tab bar used to be. I have only noticed this behavior on devices running iOS 11 deployed from XCode 9.

I found some information about SafeAreaInsets that I thought may have been causing the problem, but 0 is always returned unless I'm running on an iPhone X, so that seems to have been a bust.

Any thoughts?

Answers

  • KenHoweKenHowe USMember

    Hi Andrew,
    I'm having the same Issue, did you find a solution for this?

  • KenHoweKenHowe USMember

    Some time later.... what worked for me was:

                    TabBar.Hidden = tabBarHidden;
    
                    // The solution to the space left behind the invisible tab bar
                    if (tabBarHidden)
                    {
                        View.Subviews[1].Frame = new CoreGraphics.CGRect(View.Subviews[1].Frame.X, View.Subviews[1].Frame.Y,
                                                                         View.Subviews[1].Frame.Width, 0);
                        View.Subviews[0].Frame = new CoreGraphics.CGRect(View.Subviews[0].Frame.X, View.Subviews[0].Frame.Y,
                                                                         View.Subviews[0].Frame.Width, View.Subviews[0].Frame.Height + 49);
                    }
                    else
                    {
                        View.Subviews[1].Frame = new CoreGraphics.CGRect(View.Subviews[1].Frame.X, View.Subviews[1].Frame.Y,
                                                                         View.Subviews[1].Frame.Width, 49);
                        View.Subviews[0].Frame = new CoreGraphics.CGRect(View.Subviews[0].Frame.X, View.Subviews[0].Frame.Y,
                                                                         View.Subviews[0].Frame.Width, View.Subviews[0].Frame.Height - 49);
                    }
    
  • MarianoMariano Member
    edited March 27

    Hi @KenHowe @AndrewHoffman ! When the TabBar is hidden and then unhidden again, it looks like the font in the tab titles lose the formatting( narrow spacing and smaller size). Did you have a similar experience?

  • MdNaushadMdNaushad INMember ✭✭

    @Mariano Facing the same problem as yours. Did you find a solution for that?

Sign In or Register to comment.