I have been developing a Xamarin forms project and can't get my ToolbarItem to show my log out image. The image shows up fine in Android but in iOS it just comes up as a blue square. This may be a separate issue but clicking the log out button also will not show my notification, although that part works in Android also.
string logOutButton = Device.OnPlatform("Logout2.png", "Logout.png", "Logout.png"); home.ToolbarItems.Add(new ToolbarItem("Filter", "logOutButton", async () => { var close = DisplayAlert("Confirm Logout", "Are you sure you want to log out?", "Yes", "Cancel"); if (await close) Navigation.PopModalAsync(); }));
I attached Logout2.png so you can see the image I am trying to use
The Toolbar icons will be tinted in iOS. So you should use a monochrome png with transparent background.
You may need to enclose the DisplayAlert + PopModalAsync calls in Device.BeginInvokeOnMainThread. I'm not sure about that though. The toolbar click handler should be executed on the UI thread already, but you never know.
Answers
The Toolbar icons will be tinted in iOS. So you should use a monochrome png with transparent background.
You may need to enclose the DisplayAlert + PopModalAsync calls in Device.BeginInvokeOnMainThread. I'm not sure about that though. The toolbar click handler should be executed on the UI thread already, but you never know.
Thanks, did not know all toolbar icons are tinted in iOS.
It turns out my displayalert error was based on this issue for anyone experiencing the same thing: http://stackoverflow.com/questions/11862883/whose-view-is-not-in-the-window-hierarchy