问题描述
我正在尝试在模态内创建全角图像,但是该图像在某些iOS设备上位于导航栏的后面。
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.ModalWithFullWidthImage"
NavigationPage.HasNavigationBar="True">
<ContentPage.Content>
<StackLayout Grid.Column="0" Grid.Row="0" >
<Image Source="fullWithImage" Aspect="AspectFill" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
问题出在iPhone 11上:导航栏遮挡了图像的顶部。图像看起来好像在导航栏的后面。在iPhone 8上,图像很好。
我需要图像保持其外观,但要在宽度上保持一致。高度可以可变,并且可以在较小的设备上断开。
我希望找到一个仅使用Xaml的解决方案。我已经看到了在后面的代码中调整图像的解决方案,但是我必须相信有一个更简单的解决方案或解决方法。
解决方法
尝试将HorizontalOptions
和VerticalOptions
与FillAndExpand
添加:
<StackLayout>
<!-- Place new controls here -->
<Image Source="Images" Aspect="AspectFill" HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"/>
</StackLayout>
引用:Image with AspectFill和xamarin-forms-image-fill-width-with-proper-aspect
,您是否尝试过在ContentPage上使用home
? https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/ios/page-safe-area-layout