Reputation: 922
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.
Upvotes: 0
Views: 327
Reputation: 33993
Double-check that you are using the right icon code 
and if that is available in the font.
Since you're not getting any errors, the font should be found and registered right etc. It looks like iOS is unable to locate this specific character code within your font file.
Upvotes: 1