Can one use system icons on tabs in Xamarin Forms?

后端 未结 3 1980
遇见更好的自我
遇见更好的自我 2021-01-11 09:13

Is there a way to specify a \"system\" icon to be displayed on a tab when using Xamarin Forms? I would like to use icons such as Favourites, Bookmark, History etc but I do n

3条回答
  •  粉色の甜心
    2021-01-11 10:04

    You should write custom TabbedPage renderer for iOS project:

    public class YourTabbedRenderer : TabbedRenderer {
            public override void ViewWillAppear(bool animated)
            {
                base.ViewWillAppear(animated);
                var items = TabBar.Items;
    
                for (var i = 0; i < items.Length; i++) {
                    // set your icons here, you could do some string comparison (check tab title or tab icon resource name)
                    // items[i].Image = 
                    // items[i].SelectedImage = 
                }
            }
        }
    

    http://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/

提交回复
热议问题