Tusker/Tusker/Extensions/UIFont+Traits.swift

22 lines
556 B
Swift

//
// UIFont+Traits.swift
// Tusker
//
// Created by Shadowfacts on 9/22/19.
// Copyright © 2019 Shadowfacts. All rights reserved.
//
import UIKit
extension UIFont {
func addingTraits(_ traits: UIFontDescriptor.SymbolicTraits, size: CGFloat? = nil) -> UIFont? {
let descriptor = self.fontDescriptor
guard let newDescriptor = descriptor.withSymbolicTraits([descriptor.symbolicTraits, traits]) else {
return nil
}
return UIFont(descriptor: newDescriptor, size: size ?? self.pointSize)
}
}