With iOS 7, you can program your application to match your user preference for Dynamic Type — a larger or smaller font size. You use the method preferredFontForTextStyle:, and then listen for notifications to update the user interface if the user changes settings while your application is running. I'm wondering if you can do the same with the Bold Text accessibility setting, which is located in Settings> Accessibility. I realized that the Bold Text option actually requires a reboot of the device, so there is no need to listen to notifications, because your application will be killed and overwritten anyway.
This is what I ultimately want to accomplish: . I would like to change the title bar text of the navigation bar to a lighter font. It cannot be the default system font - it can be any font that iOS can display, but I will probably use HelveticaNeue-Light. I would also like to respect user preferences for bold text. If it is turned on, I want to change the title text to a heavier weight of the same font - exactly the same as the default iOS, although the default value is already quite heavy - Helvetica Neue Medium. Indeed, when turned on, it is a little heavier. I want to do the same with a different font.
Here is what I am doing to change it, but this will obviously be fixed no matter what the bold is:
[self.navigationController.navigationBar setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:@"HelveticaNeue-Light" size:17], [NSFontAttributeName, nil]];
I may have a solution, but it seems like a bad approach. I am creating a new font with a fixed size from preferredFontto subheadline. This is almost what I want - it automatically takes care of the font based on the Bold Text value (HelveticaNeueRegular [I really want Light] when disabled, HelveticaNeueMedium when it is turned on), but will not work for another font. Perhaps there is a better approach?
UIFont *subtitleFont = [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
UIFont *titleFont = [subtitleFont fontWithSize:17];
[self.navigationController.navigationBar setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:titleFont, NSFontAttributeName, nil]];
source
share