2019-04-27 16:49:26 +02:00
|
|
|
//
|
|
|
|
// UIFont-Extensions.swift
|
|
|
|
// NetNewsWire-iOS
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 4/27/19.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
extension UIFont {
|
|
|
|
|
|
|
|
func withTraits(traits:UIFontDescriptor.SymbolicTraits) -> UIFont {
|
2020-02-24 17:42:19 +01:00
|
|
|
if let descriptor = fontDescriptor.withSymbolicTraits(traits) {
|
|
|
|
return UIFont(descriptor: descriptor, size: 0) //size 0 means keep the size as it is
|
|
|
|
} else {
|
|
|
|
return self
|
|
|
|
}
|
2019-04-27 16:49:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func bold() -> UIFont {
|
|
|
|
return withTraits(traits: .traitBold)
|
|
|
|
}
|
|
|
|
|
|
|
|
func italic() -> UIFont {
|
|
|
|
return withTraits(traits: .traitItalic)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|