ios - fontDescriptorWithSymbolicTraits 方法返回不同字体系列中的新字体描述符引用,而不是 iOS13 上的相同字体系列
问题描述
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
解决方案
推荐阅读
- java - Java中泛型集合的迭代
- powershell - 管道对象到选择字符串出现空
- amazon-web-services - 从 Lambda 函数切换 Amazon 智能插头
- ruby - application_responder (LoadError) Rails 6
- sql - 是否可以创建 Azure SQL 数据库主主复制
- python - 在列表中查找总和为目标数字的一对数字
- java - 有没有办法在 android 中刷新 SQLite 数据库文件中的更改?
- java - Eclipse:如何从 Eclipse 配置创建独立服务器
- java - 如何使用 Gradle 命令行参数更改代码变量
- mysql - MySql Count 子句与 where