Type Method

preferredFont(forTextStyle:compatibleWith:)

Returns an instance of the system font for the appropriate text style and traits.

Declaration

class func preferredFont(forTextStyle style: UIFont.TextStyle, compatibleWith traitCollection: UITraitCollection?) -> UIFont

Parameters

style

The text style for which to return a font. See "Text Styles” in UIFontDescriptor for recognized values.

traitCollection

The traits to use when determining which font to return.

Return Value

The system font associated with the specified text style and traits.

Discussion

To create a styled font based on a custom font, use a UIFontMetrics object.

See Also

Creating Fonts

class func preferredFont(forTextStyle: UIFont.TextStyle) -> UIFont

Returns an instance of the system font for the specified text style and scaled appropriately for the user's selected content size category.

Getting a Scaled Font

Scale text in your interface automatically by creating fonts that support Dynamic Type.

Creating Self-Sizing Table View Cells

Create table view cells that support Dynamic Type and use system spacing constraints to adjust the spacing surrounding text labels.

init?(name: String, size: CGFloat)

Creates and returns a font object for the specified font name and size.

init(descriptor: UIFontDescriptor, size: CGFloat)

Returns a font matching the given font descriptor.

func withSize(CGFloat) -> UIFont

Returns a font object that is the same as the receiver but which has the specified size instead.