Fork me on GitHub

CCFont : A simple iOS and OS X CCFont replace [UIFont, NSFont], CCColor replace [UIColor, NSColor]

CCFont for iOS && OSX

=======================

英文README

简单支持 MAC OSX [>=10.9] 和 iOS [>=8]

https://github.com/ccworld1000/CCFont.git

截图 1

OSX

CCFont CCFontMac Screenshot

iOS

CCFont CCFontiOS Screenshot

CCFont

CCFont 简单支持 machosx 与 iOS, 可以简单取代 NSFont 或者 UIFont.

CCColor

CCColor 单支持 machosx 与 iOS, 可以简单取代 NSColor 或者 UIColor 十六进制字符串.

Podfile

1
pod 'CCFont'

用法

1
#import <CCUtilities.h>

1
#import <CCFont/CCUtilities.h>

演示代码

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
    HSView *p = superView;
__block NSUInteger index = 0;

CGFloat space, height, width;
space = height = 40;
width = 400;


dispatch_async(dispatch_get_main_queue(), ^{
while (index < 10) {
NSInteger i = 10 + index++;

NSString *leftText = [NSString stringWithFormat:@"L : CCFont %ld", i];
NSString *rightText = [NSString stringWithFormat:@"R : CCFont %ld", i];

#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
UILabel *l = [UILabel new];
UILabel *r = [UILabel new];
l.text = leftText;
r.text = rightText;
#else
NSTextField *l = [NSTextField new];
NSTextField *r = [NSTextField new];

l.stringValue = leftText;
r.stringValue = rightText;
#endif

l.font = [CCFont systemFontOfSize: i];
r.font = [CCFont systemFontOfSize: CCHalf(i)];

if (index % 2) {
l.textColor = [CCColor colorWithHexString:[NSString stringWithFormat:@"%f%lx%lx", 255 / (index * 1.), index * 4, index * 8]];
r.textColor = [CCColor colorWithHexString:[NSString stringWithFormat:@"%f%lx%lx", 255 / (index * 1.), index * 4, index * 8]];
} else {
l.textColor = [CCColor colorWithHexString:[NSString stringWithFormat:@"%lx%x%lx", index * 4, 255, index * 8]];
r.textColor = [CCColor colorWithHexString:[NSString stringWithFormat:@"%lx%x%lx", index * 4, 255, index * 8]];
}

l.frame = CGRectMake(CCHalf(space), index * height, CCHalf(width), height);
r.frame = CGRectMake(CCHalf(width + space), index * height, CCHalf(width), height);

[p addSubview: l];
[p addSubview: r];
}
});