I am attempting to create an effect that will style the ToolbarItem and give it a custom font. My breakpoint hits the PCL code, but it never seems to venture into the OnAttached()
override. I am wondering if there is something that I am missing. Do I have the ability to effect the actual styling on Navigation ToolbarItems?
iOS Effect Code
[assembly:ResolutionGroupName ("Core")]
[assembly:ExportEffect (typeof(ToolbarItemEffect), "ToolbarItemEffect")]
namespace Core.iOS.Effects
{
public class ToolbarItemEffect : PlatformEffect
{
protected override void OnAttached()
{
var style = new UIStringAttributes
{
Font = UIFont.FromName("FontName", 24)
};
var navigationBar = (UINavigationBar) Control;
navigationBar.TitleTextAttributes = style;
}
protected override void OnDetached()
{
}
}
}
Shared Code
public class ToolbarItemEffect : RoutingEffect
{
public ToolbarItemEffect() : base("Core.ToolbarItemEffect")
{
}
}
Xaml on Navigation Page
<ContentPage.ToolbarItems>
<ToolbarItem Text="Text" Command="{Binding TextCommand}">
<ToolbarItem.Effects>
<core:ToolbarItemEffect />
</ToolbarItem.Effects>
</ToolbarItem>-->
</ContentPage.ToolbarItems>