更改 iOS Xamarin Forms 上的导航栏高度? [英] Change Navigation bar height on iOS Xamarin Forms?
问题描述
如何在 Xamarin Forms 中更改 iOS 应用程序中 NavigationPage 导航栏的高度?实际上我有一个主详细信息页面,我想在 iOS 上更改 NavBar 高度.
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.
推荐答案
我认为您现在无法更改 iOS 中 NavigationBar 的默认高度.您可以查看此答案以获取更多信息:
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一个>
它可能适用于具有此线程中解决方案的早期 iOS 版本:
And it may work with earlier iOS version with solutions in this thread:
how-can-i-change-height-of-navigation-bar
我建议您隐藏该页面中的默认 NavigationBar 并在那里添加自定义 NavigationBar,然后您可以为自定义 NavigationBar 设置任何您想要的高度.
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.
在页面中,隐藏默认的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>
如果您想更改项目中所有导航栏的高度,您可以在那里拥有一个带有自定义 NavigationPage 的 basePage.
If you want to change the height of all the navigationBar in your project, you can have a basePage with custom NavigationPage there.
我在这里上传了一个示例项目,并在 AboutPage 中添加了自定义导航栏.您可以查看它并随时问我任何问题.
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.
这篇关于更改 iOS Xamarin Forms 上的导航栏高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!