Instance Method


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


func withSize(_ fontSize: CGFloat) -> UIFont



The desired size (in points) of the new font object. This value must be greater than 0.0.

Return Value

A font object of the specified size.

See Also

Creating Fonts

Scaling Fonts Automatically

Scale text in your interface automatically by using 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.

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

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

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

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

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.