Change to not force unwrap the descriptor. Issue #1818

This commit is contained in:
Maurice Parker 2020-02-24 08:42:19 -08:00
parent 23b8af4634
commit d222a9f617
1 changed files with 5 additions and 2 deletions

View File

@ -11,8 +11,11 @@ import UIKit
extension UIFont {
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
if let descriptor = fontDescriptor.withSymbolicTraits(traits) {
return UIFont(descriptor: descriptor, size: 0) //size 0 means keep the size as it is
} else {
return self
}
}
func bold() -> UIFont {