21

What is the name of the slim system font in iOS 7? Is there a method to use it like UIFont systemFontOfSize:?

Dmitry
  • 14,306
  • 23
  • 105
  • 189
  • 2
    Isn't it Helvetica Neue Ultra Light (or maybe just Light)? – inspector-g Sep 15 '13 at 19:56
  • Crazy people, may be you put on hold this question too: http://stackoverflow.com/questions/3838336/iphone-system-font – Dmitry Sep 15 '13 at 19:58
  • There are the answers: http://stackoverflow.com/questions/17414630/ios-7-and-helvetica-neue-ultralight-use-as-default-for-older-ios-versions – Dmitry Sep 15 '13 at 20:00

4 Answers4

27

Here is a useful reference tool for you:

http://iosfonts.com

The ones you are looking for are HelveticaNeue-Light and HelveticaNeue-UltraLight.

Nikola Kirev
  • 3,152
  • 3
  • 22
  • 30
22

As of iOS 8.2, you can now use UIFont.systemFontOfSize(_:CGFloat,weight:CGFloat):

UIFont.systemFontOfSize(19, weight: UIFontWeightLight)

iOS SDK provided constants for weights:

UIFontWeightUltraLight
UIFontWeightThin
UIFontWeightLight
UIFontWeightRegular
UIFontWeightMedium
UIFontWeightSemibold
UIFontWeightBold
UIFontWeightHeavy

Using system font is better than creating a font based on font name when you want to use system fonts since iOS can change their system fonts on iOS (like when they did with Helvetica Neue in iOS 7, and now, San Francisco in iOS 9).

chrisamanse
  • 4,289
  • 1
  • 25
  • 32
  • what was the best way before iOS 8.2 to use the system font? I was wondering how to use `systemFontOfSize` and also use some different font-weights of helvetica!? – Christian 'fuzi' Orgler Aug 04 '15 at 18:36
  • You can use `UIFont`'s initializer, `init?(name fontName: String, size fontSize: CGFloat) -> UIFont`. You have to use the font name for the font weight you need. All font names available are listed here http://iosfonts.com – chrisamanse Aug 04 '15 at 21:34
  • Yes but then I also run in the problem that this is not a good way to support both, iOS 8's HelveticaNeue and iOS 9 San Francisco. I would to have 2 specifications of the font for both OS versions in the same app. Which is not really practical at all. – Christian 'fuzi' Orgler Aug 04 '15 at 21:41
  • So the idea was to specify one font by using the `systemFontOfSize` and let the OS handle the change. But the only question I have right now is, how to get some weights in their without specifing the exact font name + the extension like "HelveticaNeue-Light" – Christian 'fuzi' Orgler Aug 04 '15 at 21:42
  • Then you have to resort to using `UIFont.systemFontOfSize(_:CGFloat,weight:CGFloat)` as stated above. – chrisamanse Aug 05 '15 at 00:17
  • But with `systemFontOfSize` there is no possibility to specify another weight then roman right? except for `boldSystemFont` but... light? medium, condensed etc. – Christian 'fuzi' Orgler Aug 10 '15 at 13:53
  • AFAIK, there is no other way. – chrisamanse Aug 11 '15 at 08:19
1

just make an extension for UIFont like below

extension UIFont {

    static func lightSystemFontOfSize(size: CGFloat) -> UIFont {

        let familyName = UIFont.systemFontOfSize(15).familyName.stringByReplacingOccurrencesOfString(" ", withString: "")

        return UIFont(name: "\(familyName)-Light", size: size)!
    }
}
Nikolay Mihaylov
  • 3,868
  • 8
  • 27
  • 32
0

Just created a category for it:

#import <UIKit/UIKit.h>

@interface UIFont (System)

+ (UIFont *)lightSystemFontOfSize:(CGFloat)fontSize;
+ (UIFont *)ultraLightSystemFontOfSize:(CGFloat)fontSize;

@end

#import "UIFont+System.h"

@implementation UIFont (System)

+ (UIFont *)lightSystemFontOfSize:(CGFloat)fontSize {
    return [UIFont fontWithName:@"HelveticaNeue-Light" size:fontSize];
}

+ (UIFont *)ultraLightSystemFontOfSize:(CGFloat)fontSize {
    return [UIFont fontWithName:@"HelveticaNeue-UltraLight" size:fontSize];
}

@end
Pedro Góes
  • 722
  • 6
  • 19