Search code examples
iosxamarin.formsnavigation-drawermaster-detailhamburger-menu

Change Navigation bar height on iOS Xamarin Forms?


How can I change Height of NavigationPage's Navigation Bar on iOS app in Xamarin Forms ? Actually I have a Master Details Page and I want to change NavBar Height on iOS.


Solution

  • I don't think you can change the default height of NavigationBar in iOS right now. You can check this answer for more information:

    cant-change-navigation-bar-height-ios-11

    And it may work with earlier iOS version with solutions in this thread:

    how-can-i-change-height-of-navigation-bar

    I would recommend you to hide the default NavigationBar in that page and add a custom NavigationBar there, then you can set any height you want to the custom NavigationBar.

    In the Page, hide the default NavigationBar:

    public AboutPage()
    {
        InitializeComponent();
    
        NavigationPage.SetHasNavigationBar(this,false);
    }
    

    And then add your custom NavigationBar:

    <StackLayout>
    
        <StackLayout HeightRequest="150" BackgroundColor="Yellow" Orientation="Horizontal">
    
            <Button Text="Menu" HorizontalOptions="Start" Padding="5"/>
            <Label Text="I'm custom navigationBar" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"/>
    
        </StackLayout>
    
        <Grid>
           <!--... my layout-->
        </Grid>
    
    </StackLayout>
    

    If you want to change the height of all the navigationBar in your project, you can have a basePage with custom NavigationPage there.

    I uploaded a sample project here and added the custom navigationBar in AboutPage. You can check it and feel free to ask me any question.