我想在RTL模式下将菜单按钮移至右侧,反之亦然,但是它对FlowDirection没有响应,我在Android中也遇到了类似的问题,并且我使用了渲染器:
class CustomNavigationPageRenderer : Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer
{
public CustomNavigationPageRenderer(Context context) : base(context) { }
private static Android.Support.V7.Widget.Toolbar GetToolbar() => (CrossCurrentActivity.Current?.Activity as MainActivity)?.FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
protected override void OnLayout(bool changed, int l, int t, int r, int b)
{
base.OnLayout(changed, l, t, r, b);
var actionBar = GetToolbar();
actionBar.LayoutDirection = Helpers.Settings.Lang == "ar" ? LayoutDirection.Rtl : LayoutDirection.Ltr;
}
}
但是不知道如何在iOS中做到这一点,我也想更改Menu
标题。
那么如何在iOS中使用导航渲染器?
编辑
MasterDetailpage(MainPage.Xaml):
<MasterDetailPage.Master>
<views:MenuPage/>
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
<x:Arguments>
<views:AllOrdersPage/>
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
cs:
public MainPage()
{
FlowDirection = Settings.FlowDirection;
InitializeComponent();
MasterBehavior = MasterBehavior.SplitOnPortrait;
}