1

我的应用程序仅使用系统字体,并且我正在使用功能创建它们 -

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

如何使用权重 UIFontWeightThin 使系统字体斜体?

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

谢谢 :)

4

2 回答 2

1

您应该首先创建包含字体类型的字体描述符,如果它是斜体、粗体或细等。

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

之后创建一个包含描述符信息的字体对象

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

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

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

于 2015-11-02T14:42:23.647 回答
0

像这样的东西怎么样:

[youLabel setFont:[UIFont fontWithName:[youLabel.font fontName] size:UIFontWeightThin]];
于 2015-11-02T14:26:23.957 回答