UIFont+YOHO.m
2.04 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// UIFont+YOHO.m
// YH_Mall
//
// Created by 张同海 on 15/5/29.
// Copyright (c) 2015年 YOHO. All rights reserved.
//
#import "UIFont+YOHO.h"
@implementation UIFont (YOHO)
+ (UIFont *)yh_lightSystemFontOfSize:(CGFloat)size
{
return [UIFont fontWithName:@"HelveticaNeue-Light" size:size];
}
+ (UIFont *)yh_blackfaceFontOfSize:(CGFloat)size
{
//STHeitiSC-Medium STHeitiSC-Light
return [UIFont fontWithName:@"STHeitiSC-Light" size:size];
}
+ (UIFont *)yh_mediumBlackfaceFontOfSize:(CGFloat)size
{
//STHeitiSC-Medium STHeitiSC-Light
return [UIFont fontWithName:@"STHeitiSC-Medium" size:size];
}
+ (UIFont *)yh_variationOfFont:(UIFont *)baseFont symbolicTraits:(CTFontSymbolicTraits)trait
{
CGFloat fontSize = [baseFont pointSize];
CFStringRef baseFontName = (__bridge CFStringRef)[baseFont fontName];
CTFontRef baseCTFont = CTFontCreateWithName(baseFontName,
fontSize, NULL);
CTFontRef ctFont = CTFontCreateCopyWithSymbolicTraits(baseCTFont, 0, NULL,trait, trait);
NSString *variantFontName = CFBridgingRelease(CTFontCopyName(ctFont, kCTFontPostScriptNameKey));
UIFont *variantFont = [UIFont fontWithName:variantFontName size:fontSize];
CFRelease(ctFont);
CFRelease(baseCTFont);
return variantFont;
}
+ (UIFont *)yh_dinMediumFontWithSize:(CGFloat)size
{
return [UIFont fontWithName:@"DIN-Medium" size:size];
}
+ (UIFont *)yh_dinRegularFontWithSize:(CGFloat)size
{
return [UIFont fontWithName:@"DIN-Regular" size:size];
}
/**
* 15-12-02 16:12:50
*
* 判断是否有PingFangSC-Light字体
*
*/
+ (UIFont *)fontOfLightWithSize:(CGFloat)fontSize
{
UIFont *font = [UIFont fontWithName:@"PingFangSC-Light" size:fontSize];
if (!font) {
font = [UIFont systemFontOfSize:fontSize];
}
return font;
}
+ (UIFont *)fontOfBoldWithSize:(CGFloat)fontSize
{
UIFont *font = [UIFont fontWithName:@"PingFangSC-Bold" size:fontSize];
if (!font) {
font = [UIFont boldSystemFontOfSize:fontSize];
}
return font;
}
@end