iOS 9中的新旧金山字体通过调整SF显示和SF文本之间的跟踪和动态切换,对其使用的大小进行了优化。在WWDC会话#804中指出,开发人员不应该通过尝试使用UIFont初始化fontWithName来使用旧金山,例如:
UIFont *originalFont = [UIFont systemFontOfSize:11];
UIFont *newFont = [UIFont fontWithName:originalFont.fontName size:44];这是因为当使用fontWithName API时,系统无法优化新大小的字体。
相反,建议从原始字体中获取UIFontDescriptor,并以新的字体大小创建新字体,如下所示:
UIFont *originalFont = [UIFont systemFontOfSize:11];
UIFont *newFont = [UIFont fontWithDescriptor:originalFont.fontDescriptor size:44];但是,它们没有提到是否允许优化:
UIFont *originalFont = [UIFont systemFontOfSize:11];
UIFont *newFont = [originalFont fontWithSize:44];我的问题是,fontWithSize API的行为是否类似于fontWithName API或fontWithDescriptor API --它是否为新大小优化字体?
发布于 2015-09-06 17:56:41
我可以确认fontWithSize确实创建了一个新大小的优化字体。
Printing description of originalFont:
<UICTFont: 0x7f8d9ba85340> font-family: ".SFUIText-Regular"; font-weight: normal; font-style: normal; font-size: 11.00pt
Printing description of newFont:
<UICTFont: 0x7f8d9ba7fe70> font-family: ".SFUIDisplay-Regular"; font-weight: normal; font-style: normal; font-size: 44.00pthttps://stackoverflow.com/questions/32426341
复制相似问题