How can we disable the effect of enabled “bold text” from settings in the iphone (in my app)? - swift 2.0

依然范特西╮ 提交于 2019-12-07 23:43:32

问题


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:


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) 
}


来源:https://stackoverflow.com/questions/32761868/how-can-we-disable-the-effect-of-enabled-bold-text-from-settings-in-the-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!