Last active
January 2, 2016 14:09
-
-
Save myell0w/8315322 to your computer and use it in GitHub Desktop.
Respect the accessibility setting "Bold Text" on iOS7, when implementing Dynamic Type with a custom font.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL MTDIsBoldTextEnabled(void) { | |
static BOOL boldTextEnabled = NO; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// Hack that checks if the "bold text" flag in the accessibility settings is enabled | |
UIFont *font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody]; | |
boldTextEnabled = [font.fontName rangeOfString:@"MediumP4"].location != NSNotFound; | |
}); | |
return boldTextEnabled; | |
} |
dispatch_once might not be a good idea - since that can be changed at runtime as well...
Wouldn't the kernel be patched (https://twitter.com/GlennF/status/400058776738205696) and all apps killed? I think dispatch_once is correct in this instance.
still running iOS 7.0.4, up until then it restarts iOS and the app gets killed. Didn't test it on iOS 7.1 Beta though.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there any less hacky way to detect this setting? I couldn't figure it out, use at own risk.