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