NSString *sampStr = @"bytedance开发者012345";
NSMutableAttributedString *fontStr = [NSMutableAttributedString new];
for(NSString * familyName in [UIFont familyNames]){
// NSLog(@"字体族科名 = %@",familyName); // 输出字体族科名字
NSAttributedString *aAttrStr = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"字体族:%@\n", familyName] attributes:@{ NSFontAttributeName: [UIFont boldSystemFontOfSize:18], NSForegroundColorAttributeName: [UIColor redColor] }];
[fontStr appendAttributedString:aAttrStr];
for(NSString *fontName in [UIFont fontNamesForFamilyName:familyName]){
// NSLog(@"\t%@",fontName); // 输出字体族科下字样名字
NSAttributedString *bAttrStr = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@:\t", fontName] attributes:@{ NSFontAttributeName: [UIFont systemFontOfSize:14] }];
[fontStr appendAttributedString:bAttrStr];
NSAttributedString *cAttrStr = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n", sampStr] attributes:@{ NSFontAttributeName: [UIFont fontWithName:fontName size:14] }];
[fontStr appendAttributedString:cAttrStr];
}
}
// textView为UITextView
self.textView.attributedText = fontStr;
05-06
8748

03-08
825
