2021-02-20 13:23:29 +01:00
|
|
|
//
|
|
|
|
// UIFont.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
2021-02-23 15:14:10 +01:00
|
|
|
// Created by BradGao on 2021/2/20.
|
2021-02-20 13:23:29 +01:00
|
|
|
//
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|