Как создать легкий шрифт из предпочтительного шрифта? - PullRequest
0 голосов
/ 29 апреля 2018

Я пытаюсь получить "легкий" шрифт из стиля шрифта UIFontTextStyle.
Независимо от кода (в stackoverflow или в doc), я всегда получаю «нормальный» шрифт веса.

Например:

    var descriptor = UIFontDescriptor.GetPreferredDescriptorForTextStyle(UIFontTextStyle.Caption2);
    att = descriptor.FontAttributes;
    att.Traits = new UIFontTraits {Weight = (float?)UIFontWeightConstants.Light};
    font = UIFont.FromDescriptor(descriptor, 0);
    //t = font.DebugDescription;

возвращает шрифт нормального веса.

1 Ответ

0 голосов
/ 29 апреля 2018

Я нашел решение. Это может кому-то помочь.

        var style = UIFontTextStyle.Caption2;
        var descriptor = UIFontDescriptor.GetPreferredDescriptorForTextStyle(style);
        var font = UIFont.FromDescriptor(new UIFontDescriptor(new UIFontAttributes
        {
            Family = descriptor.Family,
            Traits = new UIFontTraits
            {
                Weight = (float)GetFontWeight(UIFontWeight.Light)
            }
        }), descriptor.PointSize);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...