我已经在我的 xamarin 表单项目上实现了导航抽屉。我正在关注此博客以获取此功能。
它在 Android 部分工作正常,但是当我在 ios 中测试它时,抽屉项目的每一页上都会显示一个蓝色框。请看下面的截图:
我的内容页面代码:
<ContentPage.Content>
<Grid>
<StackLayout
HorizontalOptions="Fill"
VerticalOptions="FillAndExpand"
x:Name="CenteredStackLayout"
Orientation="Vertical"
BackgroundColor="White">
//Added the below codes for solving padding issue in ios part
<StackLayout>
<StackLayout.Padding>
<OnPlatform x:TypeArguments="Thickness"
Android="0, -10, 0, 0"
WinPhone="0, 0, 0, -15"
iOS="0, 15, 0, 0"/>
</StackLayout.Padding>
</StackLayout>
<BoxView BackgroundColor="#0091da">
<BoxView.Margin>
<OnPlatform x:TypeArguments="Thickness"
Android="0, -30, 0, -15"
WinPhone="0, -30, 0, -15"
iOS="0, -30, 0, -15"/>
</BoxView.Margin>
</BoxView>
<StackLayout
\\My layout fields
</StackLayout>
</Grid>
</ContentPage.Content>
在 UWP 中,导航抽屉在从中选择项目后不会关闭。
我搜索了很多,你能就这两个问题提出任何解决方案吗?
由于 ios 中的填充问题和蓝色标题问题,我在所有页面上添加了以下代码。这导致 ios 中出现蓝色框,我删除了这些代码,现在 ios 部分工作正常。
<StackLayout>
<StackLayout.Padding>
<OnPlatform x:TypeArguments="Thickness"
Android="0, -10, 0, 0"
WinPhone="0, 0, 0, -15"
iOS="0, 15, 0, 0"/>
</StackLayout.Padding>
</StackLayout>
<BoxView BackgroundColor="#0091da">
<BoxView.Margin>
<OnPlatform x:TypeArguments="Thickness"
Android="0, -30, 0, -15"
WinPhone="0, -30, 0, -15"
iOS="0, -30, 0, -15"/>
</BoxView.Margin>
</BoxView>
对于 UWP,我在 MasterDetailPage 构造函数中添加了以下代码以解决导航抽屉关闭问题:
if (Device.RuntimePlatform == Device.UWP)
{
MasterBehavior = MasterBehavior.Popover;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句