I am attempting to use a FontAwesome font in a UIBarButtonItem in a NavBar in a Xamarin Forms Project.
My XAML code
<TabbedPage.ToolbarItems>
<ToolbarItem Command="{Binding CreateNewConversation}" Text="" x:Name="NewConversationButton"></ToolbarItem>
</TabbedPage.ToolbarItems>
My CustomRenderer.cs code called inside of ViewWillAppear
var _font = UIFont.FromName("Font Awesome 5 Free", 18f);
var rightBarButtonTextAttributes = new UITextAttributes
{
Font = _font,
TextColor = UIColor.FromRGB(255, 194, 32),
TextShadowColor = UIColor.Clear
};
this.NavigationController.TopViewController.NavigationItem.RightBarButtonItem.SetTitleTextAttributes(rightBarButtonTextAttributes, UIControlState.Normal);
I can tell that the attributes are being applied as I can see the color of the text update but I am getting a ? with a square border around it. I've set a breakpoint and _font is being set with the correct font. Is there something glaringly obvious that I am doing wrong?
Update:
The issue was the lack of being able to apply a bold font weight to the UIBarButtonItem, which I'm still not sure how to do. I am able to use a different icon but whenever I change a tab the icon goes back to a square around a ? and loses its TintColor.