Type Method

fontWithName:size:

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

Declaration

+ (UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize;

Parameters

fontName

The fully specified name of the font. This name incorporates both the font family name and the specific style information for the font.

fontSize

The size (in points) to which the font is scaled. This value must be greater than 0.0.

Return Value

A font object of the specified name and size.

Discussion

You can use the fontNamesForFamilyName: method to retrieve the specific font names for a given font family.

See Also

Creating Fonts

preferredFontForTextStyle:

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

preferredFontForTextStyle:compatibleWithTraitCollection:

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

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.

fontWithDescriptor:size:

Returns a font matching the given font descriptor.

fontWithSize:

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