问题描述
iOS 13系统字体是什么?
What is the iOS 13 system font?
在iOS 13之前,我使用SFUIDisplay字体.
Before iOS 13 I used SFUIDisplay font.
UIFont(name: ".SFUIDisplay-Light", size: UIFont.systemFontSize)
但是在iOS 13上它不起作用.
But on iOS 13 it doesn't work.
推荐答案
这个错误是BS.解决该问题的唯一方法是直接使用systemFont(ofSize:weight:)
方法.再次,您无法使用方法UIFont(name:size:)
获取系统字体,出于某些有趣的原因,您只会获取Times New Roman.苹果开发人员一定在和我们搞混.因此,对于上面的原始问题,您必须使用以下代码:
This bug is so BS. The only way to get around it is by using the systemFont(ofSize:weight:)
method directly. AKA, you cannot get the system font using the method UIFont(name:size:)
, you ll just get Times New Roman for some funny reason. Apple devs must be messing with us. So for the original question above you must use the following:
UIFont(systemFont:UIFont.systemFontSize, weight: .light)
对于我的情况,我遇到了一个错误,该错误为UIFont
进行了扩展,以返回不同大小的相同字体,该字体必须与自定义字体和系统字体一起使用.为了使其能够在xcode 11 ios 13上运行,我必须添加一个愚蠢的检查以查看fontName
是否包含".SF".
For my situation, I ran into this bug making an extension for UIFont
to return the same font in a different size, which must work with custom and system fonts. In order for it to work on xcode 11 ios 13, I had to add a silly check to see if fontName
contains ".SF".
extension UIFont {
func forSize(_ pointSize: CGFloat) -> UIFont {
if !fontName.contains(".SF"), let font = UIFont(name: fontName, size: pointSize) {
return font
}
return UIFont.systemFont(ofSize: pointSize, weight: weight)
}
}
这篇关于iOS13的系统字体是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!