ios - UIFont - 如何获取系统细字体

UIFont 有获取常规字体 (systemFontOfSize) 或粗体字体 (boldSystemFontOfSize) 的方法,但是如何获取“瘦系统字体” "可通过 Storyboard获得?

将“system-thin”传递给 UIFont 构造函数不起作用,此构造函数仅适用于非系统字体。

最佳答案

你可以使用系统字体细细:

UIFont.systemFont(ofSize: 34, weight: UIFontWeightThin)

旧金山可用权重列表:

UIFontWeightUltraLight
UIFontWeightThin
UIFontWeightLight
UIFontWeightRegular
UIFontWeightMedium
UIFontWeightSemibold
UIFontWeightBold
UIFontWeightHeavy
UIFontWeightBlack

从 iOS 11 开始, UIFontWeight* 已重命名为 UIFont.Weight.*。更多你可以在这里 https://developer.apple.com/documentation/uikit/uifont.weight .

https://stackoverflow.com/questions/31771679/

相关文章:

ios - 文档 Main.storyboard 需要 Xcode 8.0 或更高版本

iphone - iOS:在代码中访问 app-info.plist 变量

objective-c - Xcode 版本 (CFBundleShortVersionString

objective-c - 一旦创建,APNS 设备 token 是否会改变?

iphone - 向下移动 UITabBarItem 图像?

iphone - Objective-C 中的弱属性和强属性 setter 属性

objective-c - ARC 是否支持调度队列?

objective-c - 如何在基于 block 的 API 方法中使用非空和可为空的 Objec

ios - 在 iOS 中创建一个整数数组

objective-c - NSString:isEqual 与 isEqualToString