在iPhone7上运行的代码截图x1c 0d1x
相同的代码运行在iPhone8 sreenshot -> flymenu封面状态栏
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<FlyoutPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:FlyOutPageDemo"
xmlns:localC="clr-namespace:FlyOutPageDemo.PageCollect"
x:Class="FlyOutPageDemo.MainPage">
<FlyoutPage.Flyout>
<local:flyOutMenuPage x:Name="flyMenu"/>
</FlyoutPage.Flyout>
<FlyoutPage.Detail>
<NavigationPage>
<x:Arguments>
<localC:Home/>
</x:Arguments>
</NavigationPage>
</FlyoutPage.Detail>
</FlyoutPage>
MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace FlyOutPageDemo
{
public partial class MainPage : FlyoutPage
{
public MainPage()
{
InitializeComponent();
flyMenu.listView.ItemSelected += ListView_ItemSelected;
}
private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var item=e.SelectedItem as FlyOutItemPage;
if (item!=null)
{
Detail=new NavigationPage((Page)Activator.CreateInstance(item.TargetPage));
flyMenu.listView.SelectedItem = null;
IsPresented=false;
}
}
}
}
flyOutMenuPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:FlyOutPageDemo"
xmlns:localCol="clr-namespace:FlyOutPageDemo.PageCollect"
x:Class="FlyOutPageDemo.flyOutMenuPage"
Title="Fly out Menu">
<ContentPage.Content>
<StackLayout>
<ListView x:Name="listView" x:FieldModifier="public">
<ListView.ItemsSource>
<x:Array Type="{x:Type local:FlyOutItemPage}">
<local:FlyOutItemPage Title="Home" IconSource="home.png" TargetPage="{x:Type localCol:Home}"/>
<local:FlyOutItemPage Title="Course" IconSource="course.png" TargetPage="{x:Type localCol:Course}"/>
<local:FlyOutItemPage Title="About" IconSource="about.png" TargetPage="{x:Type localCol:About}"/>
<local:FlyOutItemPage Title="Logout" IconSource="logout.png" TargetPage="{x:Type localCol:LogOut}"/>
</x:Array>
</ListView.ItemsSource>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="33"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding IconSource}"/>
<Label Grid.Column="1" Text="{Binding Title}"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
flyOutMenuPage.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace FlyOutPageDemo
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class flyOutMenuPage : ContentPage
{
public flyOutMenuPage()
{
InitializeComponent();
}
}
}
FlyOutItemPage.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace FlyOutPageDemo
{
class FlyOutItemPage
{
public string Title { get; set; }
public string IconSource { get; set; }
public Type TargetPage { get; set; }
}
}
以上代码运行在iPhone7屏幕截图
运行在iPhone8屏幕截图->状态栏封面flymenu
问题:如何避免Flymenu覆盖状态栏?
1条答案
按热度按时间4xrmg8kj1#
您可以手动隐藏状态栏,这将有助于避免
Flymenu
覆盖它。在Xamarin iOS应用程序中,编辑并将以下键值对添加到
Info.plist
。