Setting custom font on all UIButtons


I want to apply a custom font to all buttons in my iOS app i’ve created in Xamarin. I’ve achieved the custom font on labels with the previous code:

UILabel.Appearance.Font = UIFont.FromName("Lato-Light",16f);

…which affects some but not all buttons for some reason. Then I tried targeting the label on the button like so:

var buttonAppearance = UILabel.AppearanceWhenContainedIn(typeof (UIButton));
buttonAppearance.Font = UIFont.FromName("Lato-Light", 16f);

…which does nothing. Should I be targeting button title instead? I know there are lots of questions on here concerning how to set this in Xcode but i’m working with C# in Xamarin.iOS. Thanks!

Source: Xamarin.ios Questions

Categorised as Uncategorised Tagged , , ,


So since there is no UIButton.Appearance.Font, you can use a C# workaround I normally use.

Make an extension method like this (inside a static class):

public static void ApplyTheme(this UIButton button)
    //Set the font on the button or whatever

Then call this from code on every UIButton in your app:

//In ViewDidLoad, AwakeFromNib, etc.

This will give you styling for all buttons that you can modify as your app changes.

Willie Barton

Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us