-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIFont+FlatUI.m
executable file
·45 lines (37 loc) · 1.2 KB
/
UIFont+FlatUI.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// UIFont+FlatUI.m
// FlatUI
//
// Created by Jack Flintermann on 5/7/13.
// Copyright (c) 2013 Jack Flintermann. All rights reserved.
//
#import "UIFont+FlatUI.h"
#import <CoreText/CoreText.h>
@implementation UIFont (FlatUI)
+ (void) initialize {
[super initialize];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSArray *fontNames = @[@"Lato-Regular", @"Lato-Bold", @"Lato-Italic", @"Lato-Light"];
for (NSString *fontName in fontNames) {
NSURL * url = [[NSBundle mainBundle] URLForResource:fontName withExtension:@"ttf"];
if (url) {
CFErrorRef error;
CTFontManagerRegisterFontsForURL((__bridge CFURLRef)url, kCTFontManagerScopeNone, &error);
}
}
});
}
+ (UIFont *)flatFontOfSize:(CGFloat)size {
return [UIFont fontWithName:@"Lato-Regular" size:size];
}
+ (UIFont *)boldFlatFontOfSize:(CGFloat)size {
return [UIFont fontWithName:@"Lato-Bold" size:size];
}
+ (UIFont *)italicFlatFontOfSize:(CGFloat)size {
return [UIFont fontWithName:@"Lato-Italic" size:size];
}
+ (UIFont *)lightFlatFontOfSize:(CGFloat)size {
return [UIFont fontWithName:@"Lato-Light" size:size];
}
@end