我需要创建一个UIFont:
我正在使用此代码来解决它:
UIFontDescriptor *fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleBody];
NSArray *additionalFontSettings = @[@{UIFontFeatureTypeIdentifierKey: @(kCaseSensitiveLayoutType), UIFontFeatureSelectorIdentifierKey: @(kCaseSensitiveLayoutOnSelector)}];
fontDescriptor = [fontDescriptor fontDescriptorByAddingAttributes:@{UIFontDescriptorFeatureSettingsAttribute: additionalFontSettings, UIFontDescriptorTraitsAttribute: @{UIFontWeightTrait : @(UIFontWeightLight)}}];
return [UIFont fontWithDescriptor:fontDescriptor size:50];
我使用正确的功能启用了正确的字体,但我无法获得要遵守的字体粗细。我需要系统字体的轻量级。我如何实现这一目标?
答案 0 :(得分:0)
结果马特的提示是正确的。我忘记了您可以从现有的UIFontDescriptor
中获得UIFont
。
因此,创建这样的描述符有效:
UIFont *lightFont = [UIFont systemFontOfSize:50 weight:UIFontWeightLight];
UIFontDescriptor *fontDescriptor = lightFont.fontDescriptor;