ios - Xamarin 窗体 iOS 标题栏图标在横向打开时无法正确居中位置转为纵向
问题描述
我有一个在 Android 上不会发生的特定于 iOS 的问题。
如果应用程序中的页面以横向模式打开
然后转向标题栏中心的徽标肖像,而不是移动到中心离开页面,如下所示:
如果它以纵向打开然后变成横向,则它不会移动到中心或离开屏幕,而是向左移动,卡在全宽的四分之一左右。
xml:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="PhotoApp.MobileApp.Views.PhotoGaleryPage">
<ContentPage.Resources>
<ResourceDictionary>
<Color x:Key="Accent">#96d1ff</Color>
</ResourceDictionary>
</ContentPage.Resources>
<Shell.TitleView>
<Image
HorizontalOptions="Center"
VerticalOptions="Center"
Source="logo.png" />
</Shell.TitleView>
解决方案
我建议你使用这个:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="PhotoApp.MobileApp.Views.PhotoGaleryPage">
<ContentPage.Resources>
<ResourceDictionary>
<Color x:Key="Accent">#96d1ff</Color>
</ResourceDictionary>
</ContentPage.Resources>
<Shell.TitleView>
<StackLayout HorizontalOptions="Center"
Margin="{OnPlatform iOS='0,0,25,0', Android='0,0,20,0', Default=0}"
Orientation="Horizontal">
<Image
Source="logo.png" />
</StackLayout>
</Shell.TitleView>
推荐阅读
- python - PyTorch 中的高效批量衍生操作
- javascript - 如果数据是视频文件,如何在 mongoose 中指定我的数据类型?
- python - 使用python的nums和mods,简单的问题
- mysql - put order by in right place mysql
- email - Gmail:此邮件似乎很危险
- minecraft - Minecraft 命令方块目标选择器能否在特定的 1 方块位置搜索玩家?
- python - 使用 FMPy 模拟 OpenModelica 示例时出错
- c++ - 比较 C++ 中的 char 数组
- javascript - 用户角色层次结构
- javascript - 收到以下错误(TypeError: undefined is not an object (Evaluating 'props.route.params.contactId))