fontDescriptorWithSymbolicTraits方法返回不同字体系列的新字体描述符引用,而不是iOS13上的相同字体系列
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[ViewController bold];
}
+(UIFont *)systemFontCaption
{
return [UIFont systemFontOfSize:20.0f weight:UIFontWeightRegular];
}
+(UIFont*)bold
{
UIFont *font = [ViewController systemFontCaption];
UIFontDescriptor *fontDescriptor = [UIFontDescriptor fontDescriptorWithName:font.fontName size:font.pointSize];
UIFontDescriptor *styleDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits:[fontDescriptor symbolicTraits] | UIFontDescriptorTraitBold];
UIFont *boldFont = [UIFont fontWithDescriptor:styleDescriptor size:font.pointSize];
return boldFont;
}预期结果:
粗体字体应该在相同的字体系列中,即SFUI-Regular
实际结果:
粗体字体在不同的字体系列中,如TimesNewRoman
发布于 2019-10-29 17:30:15
https://stackoverflow.com/questions/57424602
复制相似问题