Forum Xamarin.iOS

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

iOS Navigation Bar Translucent and UseSafeArea conflict

Ed1991Ed1991 Member ✭✭

I have an issue where the "notch" is on top of my page. I want to UseSafeArea or equilevant to prevent that.

My page setup is:
CustomNavigationPage that has, that hosts a TabbedPage, that hosts ContentPage. so:
CustomNavigationPage>TabbedPage>ContentPage
Also, the TabbedPage is at the root of CustomNavigationPage, so no back button here.

I also have UINavigationBar.Appearance.Translucent = true or iOS:NavigationPage.IsNavigationBarTranslucent="True" in my CustomNavigationPage.

Result:

When I try to get the UseSafeArea Thickness using On().SafeAreaInsets(), the number it returns includes the full navigation bar size. applying that thickness results in this:

2 questions:
How can I get the thickness of the status bar only, excluding the navigation bar height?
Also need to have the content behind the navigation bar clickable. The user should be able to tap the red message behind the navigation page.

Tagged:

Answers

  • Ed1991Ed1991 Member ✭✭

    Fixed by also adding NavigationPage.HasNavigationBar="False" as it's the root page. Would still be nice to know if there is a way to keep a navigation bar, and get the right thickness (height) of status bar using On().SafeAreaInsets().

  • LeonLuLeonLu Member, Xamarin Team Xamurai
    edited December 2020

    Do you want to keep the navigationbar and you used xamarin forms? And Is red area an stacklayout? If you keep the a navigation bar, and get the right thickness (height) of status bar. You can use (int)UIApplication.SharedApplication.StatusBarFrame.Height; to get the thickness (height) of status bar

  • Ed1991Ed1991 Member ✭✭

    Yes, i would like to know how to keep the navigation bar.
    Yes it's Xamarin.Forms
    Red area is a Grid row and label inside

    So If I would to have a navigation bar visible, and put the red message below StatusBarFrame.Height, it would be behind the navigation bar?

    If so, would this red label be "tapable", or obstructed by navigation bar? Wpuld like it to be tapable

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Could you share CustomNavigationPage's code? I add SafeAreaInsets to ContentPage with following code. And keep the navigationbar.

    protected override void OnAppearing()
            {
                base.OnAppearing();
    
                var safeInsets = On<iOS>().SafeAreaInsets();
                safeInsets.Top = 20;
                Padding = safeInsets;
            }
    

    Running screenshot like blew picture.

Sign In or Register to comment.