Created
November 22, 2013 03:46
-
-
Save nuthatch/7594482 to your computer and use it in GitHub Desktop.
Map preferredContentSizeCategory into a human-readable string, e.g. UIContentSizeCategoryAccessibilityMedium becomes "Accessibility Medium"
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
+ (NSString *)preferredContentSizeDescription | |
{ | |
// see http://johnszumski.com/blog/implementing-dynamic-type-on-ios7 | |
NSString *contentSize = [UIApplication sharedApplication].preferredContentSizeCategory; | |
NSString *description; | |
if ([contentSize rangeOfString:@"Accessibility"].location != NSNotFound) | |
{ | |
// Accessibility Content Size Category Constants | |
if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityMedium]) { | |
description = @"Accessibility Medium"; | |
} else if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityLarge]) { | |
description = @"Accessibility Large"; | |
} else if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityExtraLarge]) { | |
description = @"Accessibility Extra Large"; | |
} else if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraLarge]) { | |
description = @"Accessibility 2X Large"; | |
} else if ([contentSize isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraExtraLarge]) { | |
description = @"Accessibility 3X Large"; | |
} | |
else { | |
description = @"Unknown Content Cateogry Accessibility Size"; | |
} | |
} | |
else | |
{ | |
//Content Size Category Constants | |
if ([contentSize isEqualToString:UIContentSizeCategoryExtraSmall]) { | |
description = @"Extra Small"; | |
} else if ([contentSize isEqualToString:UIContentSizeCategorySmall]) { | |
description = @"Small"; | |
} else if ([contentSize isEqualToString:UIContentSizeCategoryMedium]) { | |
description = @"Medium"; | |
} else if ([contentSize isEqualToString:UIContentSizeCategoryLarge]) { | |
description = @"Large"; | |
} else if ([contentSize isEqualToString:UIContentSizeCategoryExtraLarge]) { | |
description = @"Extra Large"; | |
} else if ([contentSize isEqualToString:UIContentSizeCategoryExtraExtraLarge]) { | |
description = @"Extra Extra Large"; | |
} else if ([contentSize isEqualToString:UIContentSizeCategoryExtraExtraExtraLarge]) { | |
description = @"Extra Extra Extra Large"; | |
} | |
else | |
{ | |
description = @"Unknown Content Cateogry Size"; | |
} | |
} | |
return description; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment