I create an extension where I set custom font
extension UILabel {
var substituteFontName : String {
get { return self.font.fontName }
set {
self.font = UIFont(name: newValue, size: self.font.pointSize)
}
}
}
but I have a problem: I get a error Unexpectedly found nil while unwrapping an Optional value, but if I set static size like this
self.font = UIFont(name: newValue, size: 13)
I didn't get a error and fonts is changing. How can I set exactly size which was automatically