編集

次の方法で共有


UIContentSizeCategory Enum

Definition

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

Name Value Description
Unspecified 0
ExtraSmall 1

Quite small.

Small 2

A small font.

Medium 3

A medium-sized font.

Large 4

A large font.

ExtraLarge 5

An extra-large font.

ExtraExtraLarge 6

A font that's larger than ExtraLarge.

ExtraExtraExtraLarge 7

A font that's larger than ExtraExtraLarge.

AccessibilityMedium 8

A medium font reflecting the current accessibility settings.

AccessibilityLarge 9

A medium font reflecting the current accessibility settings.

AccessibilityExtraLarge 10

A medium font reflecting the current accessibility settings.

AccessibilityExtraExtraLarge 11

A medium font reflecting the current accessibility settings.

AccessibilityExtraExtraExtraLarge 12

A medium font reflecting the current accessibility settings.

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...
}

Applies to