UIContentSizeCategory Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
An enumeration whose values specify the various dynamic type sizes that can be chosen by the application user.
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 7, 0, ObjCRuntime.PlatformArchitecture.All, null)]
[ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.WatchOS, ObjCRuntime.PlatformArchitecture.All, null)]
public enum UIContentSizeCategory
type UIContentSizeCategory =
- Inheritance
-
UIContentSizeCategory
- Attributes
Fields
AccessibilityExtraExtraExtraLarge | 12 | A medium font reflecting the current accessibility settings. |
AccessibilityExtraExtraLarge | 11 | A medium font reflecting the current accessibility settings. |
AccessibilityExtraLarge | 10 | A medium font reflecting the current accessibility settings. |
AccessibilityLarge | 9 | A medium font reflecting the current accessibility settings. |
AccessibilityMedium | 8 | A medium font reflecting the current accessibility settings. |
ExtraExtraExtraLarge | 7 | A font that's larger than ExtraExtraLarge. |
ExtraExtraLarge | 6 | A font that's larger than ExtraLarge. |
ExtraLarge | 5 | An extra-large font. |
ExtraSmall | 1 | Quite small. |
Large | 4 | A large font. |
Medium | 3 | A medium-sized font. |
Small | 2 | A small font. |
Unspecified | 0 |
Remarks
After the application user has set the "Text Size Property" in Settings, the application will receive a notification via ObserveContentSizeCategoryChanged. It is the application developer's responsibility, at that point, to invalidate the layout in all view elements that implement Dynamic Type. The simplest way to do that is to have a method that re-sets the font in all components that support Dynamic Type:
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...
}