How to set text font as System Thin in Swift?

<>

This question already has an answer here:

Answers


The system font in the Interface Builder is the OS default font, it is not a font you can get by it's name. For the system font Apple provides the following methods:

+ (UIFont *)systemFontOfSize:(CGFloat)fontSize;
+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize;
+ (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize;

These do not include any thin version but you can iso 8.2 you can use:

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

Where you can pass: as weights:

UIFontWeightUltraLight
UIFontWeightThin
UIFontWeightLight
UIFontWeightRegular
UIFontWeightMedium
UIFontWeightSemibold
UIFontWeightBold
UIFontWeightHeavy

So a thin system font would be:

UIFont *thinFont = [UIFont systemFontOfSize:15 weight:UIFontWeightThin];

If you're using iOS 8.2 or higher you can use this;

label.font = UIFont.systemFontOfSize(15, weight: UIFontWeightThin)

For previous versions just use HelveticaNeue-Thin as your font.


Need Your Help

WebView load website when online, load local file when offline

android webview local offline auto-update

I am actually new to programming in Java but I have been following several solutions to my problem here but didn't find one that suits my case and I can't seem to get the code down correctly.

How to get possibly overlapping matches in a string

javascript ruby regex

I'm looking for a way, either in Ruby or Javascript, that will give me all matches, possibly overlapping, within a string against a regexp.