首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >fontDescriptorWithSymbolicTraits方法返回不同字体系列的新字体描述符引用,而不是iOS13上的相同字体系列

fontDescriptorWithSymbolicTraits方法返回不同字体系列的新字体描述符引用,而不是iOS13上的相同字体系列
EN

Stack Overflow用户
提问于 2019-08-09 14:36:50
回答 1查看 225关注 0票数 6

fontDescriptorWithSymbolicTraits方法返回不同字体系列的新字体描述符引用,而不是iOS13上的相同字体系列

代码语言:javascript
复制
@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

EN

回答 1

Stack Overflow用户

发布于 2019-10-29 17:30:15

看起来苹果的属性字符串since...iOS 13测试版的字体有一个bug!但是这个问题只在Xcode 11+上出现。

Open radar

最好的解决方案是不使用系统字体,而是准确地使用字体名称。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57424602

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档