2

Is it posible to prevent the effect of enabled "BOLD TEXT" for whole ios aaplication not only for single UILable but for all of my UILable present on all uicontroller with different font sizes and style i.e Bold or SemiBold Thin etc.

Thanks in advance

Hector
  • 21
  • 2
  • 7
    Why would you want to design an app that works directly against the user's personal font preferences? If they have bold text turned on, they probably want their fonts bold everywhere, and why should you get to make the decision for them? – pbush25 Feb 17 '16 at 19:30
  • [Take a look at this](http://stackoverflow.com/questions/28180449/using-custom-font-for-entire-ios-app-swift) Just override default setting for views appearance. – Diiaablo Feb 17 '16 at 22:02
  • @pbush25 There are some Lables that has fix width and due to bold they din get in right position in short having problem to show a proper view or you can say due to bold font apps looks diminish. – Hector Feb 18 '16 at 05:27
  • @Diiaablo I have already seen the link you provided but i dont know the font size of any lable. – Hector Feb 18 '16 at 05:36

1 Answers1

0

Hope this works with you..

extension UILabel{
    
    open override func awakeFromNib() {
        if (UIAccessibility.isBoldTextEnabled) {
            if self.font.isBold{
                self.font = UIFont.preferredFont(forTextStyle: .headline)
            }
        }
    }
}

extension UIFont {
    var isBold: Bool {
        return fontDescriptor.symbolicTraits.contains(.traitBold)
    }
}