Font
public typealias Font = UIKit.UIFont
-
Mechanica
Applies the specified traits to
self
without 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() // macOS
Note
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) -> Font
Parameters
removingExistingTraits
if true only the bold trait will be applied, others traits will be removed.
Return Value
A
new
Font with the bold trait. -
Mechanica
Returns a
new
font 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() // macOS
Note
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) -> Font
Parameters
removingExistingTraits
if true only the italic trait will be applied, others traits will be removed.
Return Value
A
new
Font with the italic trait. -
Mechanica
Returns a
new
font 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 }