How to use native platform icons for ToolBarItems in Xamarin.Forms (programmatically)?

有些话、适合烂在心里 提交于 2019-12-10 22:03:07

问题


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:


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.



来源:https://stackoverflow.com/questions/27383494/how-to-use-native-platform-icons-for-toolbaritems-in-xamarin-forms-programmatic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!