Я внедряю вкладки в iOS, используя Xamarin.Forms TabbedRenderer
.Но на вкладках скрываются значки после перехода на дочерние страницы.
Ниже приведен мой код
public class CustomTabRenderer_iOS : TabbedRenderer
{
public override void ViewWillLayoutSubviews()
{
base.ViewWillLayoutSubviews();
foreach (var item in TabBar.Items)
{
item.Image = GetTabIcon(item.Title);
}
}
private UIImage GetTabIcon(string title)
{
UITabBarItem item = null;
switch (title)
{
case "Dairy":
item = new UITabBarItem("Dairy", UIImage.FromFile("dairy"), 0);
break;
case "My kid":
item = new UITabBarItem("My kid",UIImage.FromFile("kid"),0);
break;
case "Events":
item = new UITabBarItem("Events", UIImage.FromFile("events"), 0);
break;
case "About":
item = new UITabBarItem("About", UIImage.FromFile("about"), 0);
break;
}
var img = (item != null) ? UIImage.FromImage(item.SelectedImage.CGImage, item.SelectedImage.CurrentScale, item.SelectedImage.Orientation) : new UIImage();
return img;
}
}
Это страница Attendance.xaml
<?xml version="1.0" encoding="utf-8" ?>
<Shared:CToolbarPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="edTheSIS.Pages.Attendance"
Title="My Kid"
Icon="kid"
xmlns:Shared="clr-namespace:edTheSIS.Shared;assembly=edTheSIS">
<ContentPage.Content>
<StackLayout>
<Label Text="This is attendance..!"
</StackLayout>
</ContentPage.Content>
</Shared:CToolbarPage>
Событие нажатия кнопки «Присутствие ниже»
private async void CreateTabs()
{
var tp = new MyTabbedPage();
tp.Children.Add(new DairyTabPage());
tp.Children.Add(new Attendance());
tp.Children.Add(new Events());
tp.Children.Add(new About());
tp.CurrentPage = tp.Children[1];
await Navigation.PushAsync(tp);
}
Для получения дополнительной информации см. Снимок экрана ниже, где значок вкладки «Мой ребенок» не отображается