I need to change the font of all the UILables, UITextViews, UITextFields, UIButtons (title), in the app based on the content of the text or title. How can I do this globally?.
I did try to create an extension for each and make the changes in layoutSubviews(), but this only worked for UILabels.
extension UILabel {
override open func layoutSubviews() {
super.layoutSubviews()
let text = self.text ?? ""
var fontName = THEME_FONT_NAME
if (!text.isAlphanumeric) {
self.font = UIFont.systemFont(ofSize: self.font.pointSize, weight: fontWeight)
return
}
self.font = UIFont(name: fontName, size: self.font.pointSize)
}}