IOS 上的 Xamarin 工具栏项未正确对齐 [英] Xamarin toolbar item on IOS not aligning properly

查看:30
本文介绍了IOS 上的 Xamarin 工具栏项未正确对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Xamarin 应用程序的 IOS 版本上很难将工具栏项对齐到最右侧,但在 Android 版本上,它工作得非常好并将工具栏项对齐到工具栏的最右侧.

I am having difficulty in aligning a toolbar item to the far right on the IOS build of a Xamarin application, although, on the Android build, it works perfectly fine and aligns the toolbar item to the far right of the toolbar.

工具栏项的 XML 代码:

XML code for the toolbar item:

<ContentPage.ToolbarItems x:Uid="ToolbarName">
    <ToolbarItem x:Name="Settings" Order="Primary" Icon="cog.png" Priority="0" Clicked="Settings_Clicked" />
</ContentPage.ToolbarItems>

IOS 构建工具栏:

我不想过多更改 XML,因为我担心它会影响 android 构建.

I do not want to change the XML too much as I am worried that it will then effect the android build.

对此事的任何帮助将不胜感激.

Any help on the matter would be greatly appreciated.

谢谢.

推荐答案

这是一个已知的 issue Xamarin ToolbarItems,您可以尝试更新您的 Xamarin Forms 版本以查看问题是否已修复.

This is a known issue of the Xamarin ToolbarItems, you could try update you Xamarin Forms version to see if the issue was fixed.

解决方法是使用 NavigationPage.TitleView (来源)

A workaround would be using a NavigationPage.TitleView (source)

<ContentPage>
    <NavigationPage.TitleView>
        <StackLayout Orientation="Horizontal" VerticalOptions="End" Spacing="10" HorizontalOptions="End">
            <Image Source="cog.png">               
            </Image>           
        </StackLayout>
    </NavigationPage.TitleView>
</ContentPage>

这篇关于IOS 上的 Xamarin 工具栏项未正确对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆