9

I am using Xamarin Studio to develop an iOS iPad app. I need to assign the System font name to a variable in the code behind on one of the pages.

How do I get whatever the System font is programmatically?

Dave Haigh
  • 4,369
  • 5
  • 34
  • 56

2 Answers2

24

NOTE: Before somebody thinks he has to change this answer: This is answering a question about Xamarin.iOS and not ObjectiveC. The API really uses uppercase properties and method names.

Create a system UIFont and read its properties:

var font = UIFont.SystemFontOfSize(10);
string familyName = font.FamilyName;
string fontName = font.Name;

See also Apple's reference for UIFont.

Krumelur
  • 32,180
  • 27
  • 124
  • 263
5

Starting with iOS7, you have a richer way of getting the font, using the new UIFont properties.

For details see:

http://tirania.org/monomac/archive/2013/Sep-25.html

miguel.de.icaza
  • 32,654
  • 6
  • 58
  • 76