How can we disable the effect of enabled “bold tex

2019-05-23 01:38发布

If the user’s device has bold text enabled there are certain parts of the system that will automatically respond to that. For example, if you are using a default navigation controller in your app, the title and the UIBarButtonItem at the top of the screen will become bold.

How can I disable the effect of bold text to all my app and specially to the default navigation controller ( to the title and the UIBarButtonItem ) in my app ? - swift 2.0 ( iOS 8 & 9 ) . thx all : )

I have this code to detect if the bold text is enabled : (if it is useful)

 if (UIAccessibilityIsBoldTextEnabled()) { // use bold font 
       }
 else { 
    // use standard font
}

1条回答
爷、活的狠高调
2楼-- · 2019-05-23 02:27

If your Bar Button Item is using default(System) font, and if the user enable bold text, your screen text changes Bold. Customize font of your bar button item with regular text.

let barButton = UIBarButtonItem.appearance()
if let font = UIFont(name: "HelveticaNeue", size: 19) {     
    barButton.setTitleTextAttributes([NSFontAttributeName: font], forState: UIControlState.Normal) 
}
查看更多
登录 后发表回答