- uiFontTextStyle
- Name of one of the built-in system text styles.
UIFont
You can instead use the UIFont.PreferredBody, UIFont.PreferredCaption1, UIFont.PreferredCaption2, UIFont.PreferredHeadline, UIFont.PreferredSubheadline properties to get this information.
Using these methods to obtain an initial font during view intiailization is not sufficient to implement dynamic type. After the application user has set the "Text Size Property" in Settings, the application will receive a notification via UIApplication.Notifications.ObserveContentSizeCategoryChanged. It is the application developer's responsibility, at that point, to invalidate the layout in all view elements that should be resized. The simplest way to do that is to have a method that re-sets the font in all components that support Dynamic Type:
C# Example
UIApplication.Notifications.ObserveContentSizeCategoryChanged((s,e) => { SetDynamicTypeFonts(); }); //Call this when initializing, and also in response to ObserveContentSizeCategoryChanged notifications private void SetDynamicTypeFonts() { headlineLabel.Font = UIFont.PreferredFontForTextStyle(UIFontTextStyle.Headline); bodyText.Font = UIFont.PreferredFontForTextStyle(UIFontTextStyle.Body); //...etc... }
This can be used from a background thread.