Instance Method

withDesign(_:)

Returns a new font descriptor that is the same as the existing descriptor, but with the specified design.

Declaration

func withDesign(_ design: UIFontDescriptor.SystemDesign) -> UIFontDescriptor?

Parameters

design

The new system font design.

Return Value

The new font descriptor, if the original font descriptor is from a system UI font; otherwise, nil.

Discussion

This method changes the design of an existing font descriptor that describes a system UI font—for example, a font descriptor created by methods such as systemFont(ofSize:), preferredFont(forTextStyle:), or preferredFontDescriptor(withTextStyle:). If the original font descriptor does not describe a system font, this method returns nil.

See Also

Creating a Font Descriptor

class func preferredFontDescriptor(withTextStyle: UIFont.TextStyle) -> UIFontDescriptor

Returns a font descriptor containing the given text style and the user's selected content size category.

class func preferredFontDescriptor(withTextStyle: UIFont.TextStyle, compatibleWith: UITraitCollection?) -> UIFontDescriptor

Returns a font descriptor containing the text style and the content size category specified by the provided trait collection.

init(name: String, matrix: CGAffineTransform)

Returns a font descriptor with the UIFontDescriptorNameAttribute and UIFontDescriptorMatrixAttribute dictionary attributes set to the given values.

init(name: String, size: CGFloat)

Returns a font descriptor with the UIFontDescriptorNameAttribute and UIFontDescriptorSizeAttribute dictionary attributes set to the given values.

func addingAttributes([UIFontDescriptor.AttributeName : Any]) -> UIFontDescriptor

Returns a new font descriptor that is the same as the existing descriptor, but with the specified attributes taking precedence over the existing ones.

func withFamily(String) -> UIFontDescriptor

Returns a new font descriptor whose attributes are the same as the existing font descriptor, but from the specified family.

func withFace(String) -> UIFontDescriptor

Returns a new font descriptor that is the same as the existing font descriptor, but with the specified face.

func withMatrix(CGAffineTransform) -> UIFontDescriptor

Returns a new font descriptor that is the same as the existing font descriptor, but with the specified matrix.

func withSize(CGFloat) -> UIFontDescriptor

Returns a new font descriptor that is the same as the existing font descriptor, but with the specified point size.

func withSymbolicTraits(UIFontDescriptor.SymbolicTraits) -> UIFontDescriptor?

Returns a new font descriptor that is the same as the existing font descriptor, but with the specified symbolic traits.