Created
November 9, 2014 22:06
-
-
Save zwaldowski/f29374e4069044811d9e to your computer and use it in GitHub Desktop.
Dynamic Type with Weight-Matching
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
@implementation UIFontDescriptor (DZWDynamicType) | |
+ (instancetype)dzw_preferredFontDescriptorWithTextStyle:(NSString *)style { | |
return [[self preferredFontDescriptorWithTextStyle:style] dzw_fontDescriptorWithMatchingFamily:@"Avenir Next"]; | |
} | |
- (instancetype)dzw_fontDescriptorWithMatchingFamily:(NSString *)family { | |
NSMutableDictionary *attributes = [self.fontAttributes mutableCopy]; | |
[attributes removeObjectForKey:UIFontDescriptorTextStyleAttribute]; | |
UIFontDescriptor *newDesc = (__bridge_transfer UIFontDescriptor *)CTFontDescriptorCreateCopyWithFamily((__bridge CTFontDescriptorRef)self, (__bridge CFStringRef)family); | |
[attributes addEntriesFromDictionary:newDesc.fontAttributes]; | |
return [self.class fontDescriptorWithFontAttributes:attributes]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment