如何更改导航栏中标题的位置
答
You will need a custom render, here's how i have done it in IOS: (the thing is no way to you to get info from tamarin forms for the UIToolbarItem, so you can use the title to get the button u want or hardcode.
(this code, shows moving the 1st button to the left, leaving the other 2 buttons on the right) attached a screenshot
Create a custom PageRenderer to the page type where you want to access,
[assembly: ExportRenderer(typeof(CategoriesPage), typeof(CategoriesPageRenderer))]
and add
bool updatedButtons = false;
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear (animated);
if (!updatedButtons)
MoveButtonToLeft();
}
protected void MoveButtonToLeft()
{
var infoButton = NavigationController.TopViewController.NavigationItem.RightBarButtonItems[0];
NavigationController.TopViewController.NavigationItem.LeftBarButtonItem = infoButton;
var favButton = NavigationController.TopViewController.NavigationItem.RightBarButtonItems[1];
var musicButton = NavigationController.TopViewController.NavigationItem.RightBarButtonItems[2];
NavigationController.TopViewController.NavigationItem.RightBarButtonItems = new UIBarButtonItem[2] {favButton, musicButton };
updatedButtons = true;
}
看看'CustomRenderers' https://developer.xamarin.com/guides/xamarin-forms/custom-renderer/ –