0

I am working on an app and it very painful and time consuming to update font family for each label and other text elements used in xcode.

Is there any way we can update the font family of all label, text fields etc globally without changing the font-size.

I used this code in swift 3 and worked perfectly

Set a default font for whole iOS app?

extension UILabel {

    var substituteFontName : String {
        get { return self.font.fontName }
        set { self.font = UIFont(name: newValue, size: self.font.pointSize) }
    }
}

but in swift 4 it shows this error

Fatal error: Unexpectedly found nil while unwrapping an Optional value on line

set { self.font = UIFont(name: newValue, size: self.font.pointSize) }

Thanks

Nabeel
  • 841
  • 1
  • 10
  • 23

0 Answers0