Учитывая следующий код и устройство под управлением iOS 7.1 или более поздней версии:
NSDictionary *fontTraitsDictionary = @{UIFontWeightTrait : @(-1.0)};
NSDictionary *attributesDictionary = @{
UIFontDescriptorFamilyAttribute : @"Helvetica Neue",
UIFontDescriptorTraitsAttribute : fontTraitsDictionary
};
UIFontDescriptor *ultraLightDescriptor = [UIFontDescriptor fontDescriptorWithFontAttributes:attributesDictionary];
UIFont *shouldBeAnUltraLightFont = [UIFont fontWithDescriptor:ultraLightDescriptor size:24];
NSLog(@"%@", shouldBeAnUltraLightFont);
Я ожидал бы, что значение shouldBeAnUltraLightFont
будет экземпляром HelveticaNeue-UltraLight, но это:
<UICTFont: 0x908d160> font-family: "Helvetica"; font-weight: normal; font-style: normal; font-size: 24.00pt
Я слежу за документацией Apple, насколько я понимаю. Почему семейство шрифтов и информация о весе шрифта полностью игнорируются?
Вещи Ive пробовали
- Я пробовал другие фамилии, такие как Helvetica, Avenir и т.д.
- Я пробовал другие шрифты шрифтов в допустимом диапазоне от -1 до 1 с шагом 0,25
Независимо от этих изменений, возвращаемый шрифт всегда является ванильным экземпляром Helvetica при нормальном весе.