Xamarin views are overlapped by the UINavigationBar when set to be translucent

121 views Asked by At

I have a Xamarin.Forms app and want to set the NavigationBar to be translucent. But when I do, I get a strange behavior with the Xamarin views:

ListViews or TableViews behave correctly. But when I wrap them in a RefreshView, they are overlapped by the UINavigationBar.

-- TRANSLUCENCY WITHOUT REFRESHVIEW: OKAY

<ContentPage>
    <ListView>
        ...
    </ListView>
</ContentPage>
-- TRANSLUCENCY WITHOUT REFRESHVIEW: BUGGY

<ContentPage>
    <RefreshView>     <----
        <ListView>
            ...
        </ListView>
    </RefreshView>
</ContentPage>

Xamarin.Forms views hide behind the UINavigationBar if set to be translucent.

Am I missing something?

1

There are 1 answers

2
Junior Jiang On

We can use navigationPage.BarBackgroundColor = Color.Transparent to achieve that .

NavigateFromMenu method modified as follow :

case (int)MenuItemType.TranslucentWithoutRefreshView:
    MenuPages.Add(id, CreateTranslucentNavigationPage(new TranslucentWithRefreshPage(),false));
    break;
case (int)MenuItemType.TranslucentWithRefreshView:
    MenuPages.Add(id, CreateTranslucentNavigationPage(new TranslucentWithRefreshPage(),true));
    break;

Then in CreateTranslucentNavigationPage method :

private Xamarin.Forms.NavigationPage CreateTranslucentNavigationPage(Xamarin.Forms.Page page, bool value)
{
    var navigationPage = new Xamarin.Forms.NavigationPage(page);
    if (value)
    {
        navigationPage.BarBackgroundColor = Color.Transparent;
        navigationPage.BarTextColor = Color.Black;
    }
    //Xamarin.Forms.PlatformConfiguration.iOSSpecific.NavigationPage.SetIsNavigationBarTranslucent(navigationPage, true);
    return navigationPage;
}

The effect :

enter image description here