123456789101112131415161718192021222324 |
- //
- // UIFont.swift
- // Mastodon
- //
- // Created by BradGao on 2021/2/20.
- //
- import UIKit
- extension UIFont {
- private func withTraits(traits: UIFontDescriptor.SymbolicTraits) -> UIFont {
- let descriptor = fontDescriptor.withSymbolicTraits(traits)
- return UIFont(descriptor: descriptor!, size: 0) //size 0 means keep the size as it is
- }
-
- func bold() -> UIFont {
- return withTraits(traits: .traitBold)
- }
-
- func italic() -> UIFont {
- return withTraits(traits: .traitItalic)
- }
- }
|