mastodon-ios/Mastodon/Extension/UIFont.swift

24 lines
534 B
Swift

//
// 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)
}
}