繁体   English   中英

如何更改 xamarin.forms ios 上的导航栏标题图标?

[英]how to change navigation bar title icon on xamarin.forms ios?

我想更改我的 xamarin.forms ios 应用程序上的导航栏标题图标。您可以在附加图像中找到请求的点。 app_screenshot

你可以通过在 Xamarin.Forms 上使用自定义呈现来实现这一点。 由于每个UIViewController都有自己的NavigationItem ,因此您应该在要修改其LeftBarButtonItem特定页面中执行此LeftBarButtonItem 这是我的渲染器供您参考:

[assembly: ExportRenderer(typeof(CustomPage), typeof(CustomPageRenderer))]
namespace UIBarButtomItemsForms.iOS
{
    public class CustomPageRenderer : PageRenderer
    {
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);


        }

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var navigationItem = NavigationController.TopViewController.NavigationItem;

            UIBarButtonItem leftItem = new UIBarButtonItem(UIImage.FromBundle("Image.png"), UIBarButtonItemStyle.Plain, (sender, args) =>
            {

            });

            navigationItem.SetLeftBarButtonItem(leftItem, false);
        }
    }
}

然后在表单上你可以使用这个CustomPage ,请注意你应该让你的MainPage包装在NavigationPageMainPage = new NavigationPage(new MainPage());

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM