gpt4 book ai didi

ios - 如何在 iOS 9 的 UILabel 中获取等宽数字

转载 作者:IT王子 更新时间:2023-10-29 07:52:06 44 4
gpt4 key购买 nike

At WWDC 2015, there was a session about the new “San Francisco” system font在 iOS 9 中。当链接到 iOS 9 SDK 时,它默认使用比例数字渲染而不是等宽数字。 NSFont 上有一个方便的初始化程序,称为 NSFont.monospacedDigitsSystemFontOfSize(mySize weight:),可用于显式启用等宽数字显示。

但是我在 UIFont 上找不到与此等效的 UIKit

最佳答案

自 iOS 9 以来,这在 UIFont 中可用:

+ (UIFont *)monospacedDigitSystemFontOfSize:(CGFloat)fontSize weight:(CGFloat)weight NS_AVAILABLE_IOS(9_0);

例如:

[UIFont monospacedDigitSystemFontOfSize:42.0 weight:UIFontWeightMedium];

或者在 Swift 中:

UIFont.monospacedDigitSystemFont(ofSize: 42.0, weight: UIFontWeightMedium)

关于ios - 如何在 iOS 9 的 UILabel 中获取等宽数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30854690/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com