gpt4 book ai didi

iOS - 是否可以使 UIFont SystemFont 斜体和细(不使用 fontWithName :)?

转载 作者:行者123 更新时间:2023-11-29 12:10:52 24 4
gpt4 key购买 nike

我的应用仅使用系统字体,我正在使用函数创建它们 -

+ (UIFont * _Nonnull)systemFontOfSize:(CGFloat)fontSize weight:(CGFloat)weight

如何使粗细为 UIFontWeightThin 的系统字体变为斜体?

我不能使用对特定系列字体 (fontWithName:) 的调用,因为我希望它只是系统字体。

谢谢:)

最佳答案

您应该首先创建字体描述符,其中包含您的字体类型(斜体、粗体或细体等)。

UIFontDescriptor* desc = [UIFontDescriptor fontDescriptorWithFontAttributes:
@{
UIFontDescriptorFaceAttribute: @"Thin"
}
];

然后创建一个保存描述符信息的字体对象

UIFont *font = [UIFont fontWithDescriptor:desc size:17];

因此,将字体对象设置为标签。

现在你得到了一个使用系统字体的字体对象,但你可以在不使用 fontWithName 的情况下更改它的类型和大小。

关于iOS - 是否可以使 UIFont SystemFont 斜体和细(不使用 fontWithName :)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33476610/

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