Font
public typealias Font = UIKit.UIFont
-
Mechanica
Applies the specified traits to
selfwithout changing the current size.Declaration
Swift
public func withTraits(_ traits: FontDescriptorSymbolicTraits) -> Font -
Mechanica
Applies the bold trait.
Example:
let font = Font.preferredFont(forTextStyle: .body).bold() // iOS/tvOS/watchOS let font = Font.systemFont(ofSize: 16).bold() // macOSNote
iOS, watchOS, tvOSSpecial care is required when working with a descriptor generated by
preferredFont(forTextStyle:). Not all fonts support all traits. The headline font, for instance, is weighted according to the user’s preferred content size and even if you can strip the descriptor of its bold trait, the matching UIFont will be bold.Declaration
Swift
public func bold(removingExistingTraits: Bool = true) -> FontParameters
removingExistingTraitsif true only the bold trait will be applied, others traits will be removed.
Return Value
A
newFont with the bold trait. -
Mechanica
Returns a
newfont removing the bold trait.Declaration
Swift
public func removingBold() -> Font -
Mechanica
Applies the italic trait.
Example:
let font = Font.preferredFont(forTextStyle: .body).italic() // iOS/tvOS/watchOS let font = Font.systemFont(ofSize: 16).italic() // macOSNote
iOS, watchOS, tvOSSpecial care is required when working with a descriptor generated by
preferredFont(forTextStyle:). Not all fonts support all traits. The headline font, for instance, is weighted according to the user’s preferred content size and even if you can strip the descriptor of its bold trait, the matching UIFont will be bold.Declaration
Swift
public func italic(removingExistingTraits: Bool = false) -> FontParameters
removingExistingTraitsif true only the italic trait will be applied, others traits will be removed.
Return Value
A
newFont with the italic trait. -
Mechanica
Returns a
newfont removing the italic trait.Declaration
Swift
public func removingItalic() -> Font -
Mechanica
Returns true if the font contains the bold trait.
Declaration
Swift
public var isBold: Bool { get } -
Mechanica
Returns true if the font contains the italic trait.
Declaration
Swift
public var isItalic: Bool { get }
Font Extension Reference