Class

UIFontMetrics

A utility object for obtaining custom fonts that scale to support Dynamic Type.

Declaration

@interface UIFontMetrics : NSObject

Overview

Use a UIFontMetrics object to support scalable custom fonts in your app. You create a font metrics object that specifies the font style—for example, body or title—that you want to use in your app. You then pass your custom font to the scaledFontForFont: method (or one of the other methods of this class) to obtain a font object that is based on your custom font, has the appropriate style information, and automatically scales to match the current Dynamic Type settings.

Topics

Creating a Font Metrics Object

- initForTextStyle:

Creates a font metrics object for the specified text style.

+ metricsForTextStyle:

Creates and returns a font metrics object for the specified text style.

defaultMetrics

The default font metrics object for content.

UIFontTextStyle

Constants that describe the preferred styles to use for fonts.

Creating Scaled Fonts

Scaling Fonts Automatically

Scale text in your interface automatically by using Dynamic Type.

- scaledFontForFont:

Returns a version of the specified font that adopts the current font metrics.

- scaledFontForFont:compatibleWithTraitCollection:

Returns a version of the specified font that adopts the current font metrics and supports the specified traits.

- scaledFontForFont:maximumPointSize:

Returns a version of the specified font that adopts the current font metrics and is constrained to the specified maximum size.

- scaledFontForFont:maximumPointSize:compatibleWithTraitCollection:

Returns a version of the specified font that adopts the current font metrics and is constrained to the specified traits and size.

Scaling Layout Values

- scaledValueForValue:

Scales an arbitrary layout value based on the current Dynamic Type settings.

- scaledValueForValue:compatibleWithTraitCollection:

Scales an arbitrary layout value based on the current Dynamic Type settings and the specified traits.

Relationships

Inherits From

See Also

Fonts

Scaling Fonts Automatically

Scale text in your interface automatically by using Dynamic Type.

Adding a Custom Font to Your App

Add a custom font to your app and use it in your app’s interface.

UIFont

The interface for getting and setting font information.

UIFontDescriptor

Describes a font with a dictionary of attributes.

UIFontDescriptorSymbolicTraits

A symbolic description of the stylistic aspects of a font.

UIContentSizeCategoryAdjusting

A collection of methods that give controls an easy way to adopt automatic adjustment to content category changes.