In Swift 3, I used the following to replace all fonts in BOLD to MEDIUM in AppDelegate:
UILabel.appearance().substituteFontNameBold = "HelveticaNeue-Medium"
And by adding this extension to UILabel :
extension UILabel {
var substituteFontNameBold : String {
get { return self.font.fontName }
set {
if self.font.fontName.contains("Bold") {
self.font = UIFont(name: newValue, size: self.font.pointSize)
}
}
}
}
With the upgrade to Swift 4, I get a "fatal error: unexpectedly found nil while unwrapping an Optional value" on
if self.font.fontName.contains("Bold") {
How can I continue to replace all fonts in BOLD to MEDIUM in labels with Swift 4?