1
votes

My app uses only system fonts, and I am creating them with function -

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

How Can I make System font Italic with weight UIFontWeightThin?

I cannot use the call for specific family font (fontWithName:) since I want it to be system fonts only.

Thanks :)

2
Possible duplicate of UILabel font : bold and italicAlex Cio
You might want to take a look at this answer stackoverflow.com/a/17977354/2268168Sudo
I don't want to use UIFont fontWithName: since I want it to be the System font (Helvetica for ios 8, SF for ios 9 etc.)Talia Segev

2 Answers

1
votes

You should create Font Descriptor at first that contain the type of your font if it Italic or Bold or Thin, etc..

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

after that create a font object that hold the descriptor information

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

So, set you font object to your label.

Now you got a font object using system font but you can change the the type and size of it without using fontWithName.

0
votes

What about something like this:

[youLabel setFont:[UIFont fontWithName:[youLabel.font fontName] size:UIFontWeightThin]];