Я нашел решение для доступа к верхней вкладке / панели инструментов для iOS на страницах Shell. Вам нужен подкласс ShellSectionRootHeader
, который сам является подклассом UICollectionViewController
, который является собственным типом, который отображает верхнюю панель вкладок на iOS. Когда у вас есть этот подкласс, вы можете переопределить метод GetCell
, чтобы получить каждый отдельный элемент в верхней панели вкладок и изменить их. Но для того, чтобы добраться до этой точки, вам необходимо создать подкласс и создать еще 2 рендерера помимо ShellRenderer
.
Вот пример кода рендерера в iOS:
[assembly: ExportRenderer(typeof(Shell), typeof(CustomShellRenderer))]
namespace Xaminals.iOS
{
public class CustomShellRenderer: ShellRenderer
{
protected override IShellSectionRenderer CreateShellSectionRenderer(ShellSection shellSection)
{
var shellSectionRenderer = new CustomShellSectionRenderer(this);
return shellSectionRenderer;
}
}
public class CustomShellSectionRenderer : ShellSectionRenderer
{
public CustomShellSectionRenderer(IShellContext context) : base(context)
{ }
protected override IShellSectionRootRenderer CreateShellSectionRootRenderer(ShellSection shellSection, IShellContext shellContext)
{
var renderer = new CustomShellSectionRootRenderer(shellSection, shellContext);
return renderer;
}
}
public class CustomShellSectionRootRenderer : ShellSectionRootRenderer
{
public CustomShellSectionRootRenderer(ShellSection section, IShellContext context) : base(section, context)
{ }
protected override IShellSectionRootHeader CreateShellSectionRootHeader(IShellContext shellContext)
{
var renderer = new CustomShellSectionRootHeader(shellContext);
return renderer;
}
}
public class CustomShellSectionRootHeader : ShellSectionRootHeader
{
public CustomShellSectionRootHeader(IShellContext context) : base(context)
{
}
public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
{
var cell = base.GetCell(collectionView, indexPath) as ShellSectionHeaderCell;
// Set desired font here
//cell.Label.Font = UIFont.ItalicSystemFontOfSize(11);
var layout = new UICollectionViewFlowLayout();
layout.MinimumInteritemSpacing = UIScreen.MainScreen.Bounds.Size.Width / 8;
layout.SectionInset = new UIEdgeInsets(top: 0, left: UIScreen.MainScreen.Bounds.Size.Width/4, bottom: 0, right: 0);
collectionView.CollectionViewLayout = layout;
return cell;
}
}
public class CustomUICollectionViewFlowLayout : UICollectionViewFlowLayout
{
public override UICollectionViewLayoutAttributes[] LayoutAttributesForElementsInRect(CGRect rect)
{
return base.LayoutAttributesForElementsInRect(rect);
}
}
}
Эффект:
введите описание изображения здесь