How to use native platform icons for ToolBarItems

2019-07-07 02:11发布

What I have:

I have a Xamarin.Forms app with a ToolBar (ActionBar on Android, Navigation Bar on iOS). Within the ToolBar I have a ToolBarItem to delete something.

What I want:

For the ToolBarItem mentioned above I want to use the native platform icons (f.e. a trash can).

My question:

What is the proper way to achieve this? It seems that the only way to do this is to add and load separate png-files as described here. For Android this is not such a big deal I can officially download the icon files from Google's developer page. For iOS this is not possible.

1条回答
手持菜刀,她持情操
2楼-- · 2019-07-07 03:13

Currently this looks to be almost impossible to override. Looking at the source for ToolbarRenderer you can see the UpdateItems method. This assumes that all of the toolbar items are of type ToolbarItem and it does not invoke a custom renderer for them, instead calling through directly to an extension method that converts ToolbarItem values into UIBarButtonItems containing a UIImage.

查看更多
登录 后发表回答