Repository navigation
Expand file tree
/
Copy pathSCISymbol.m
More file actions
87 lines (59 loc) · 2.03 KB
/
Copy pathSCISymbol.m
File metadata and controls
87 lines (59 loc) · 2.03 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
82
83
84
85
86
87
#import "SCISymbol.h"
@interface SCISymbol ()
@property (nonatomic, copy, readwrite) NSString *name;
@property (nonatomic, copy, readwrite) UIColor *color;
@property (nonatomic, readwrite) CGFloat size;
@property (nonatomic, readwrite) UIImageSymbolWeight weight;
- (instancetype)init;
@end
///
@implementation SCISymbol
// MARK: - Instance methods
- (instancetype)init {
self = [super init];
if (self) {
self.name = @"";
self.color = [UIColor labelColor];
self.weight = UIImageSymbolWeightRegular;
self.size = 15.0;
}
return self;
}
- (UIImage *)image {
UIImage *symbol = [UIImage systemImageNamed:self.name];
if (self.size || (self.size && self.weight)) {
UIImageSymbolConfiguration *symbolConfig = [UIImageSymbolConfiguration configurationWithTextStyle:UIFontTextStyleTitle1];
symbolConfig = [symbolConfig configurationByApplyingConfiguration:
[UIImageSymbolConfiguration configurationWithPointSize:self.size weight:self.weight]];
return [symbol imageWithConfiguration:symbolConfig];
}
return symbol;
}
// MARK: - Class methods
+ (instancetype)symbolWithName:(NSString *)name {
SCISymbol *symbol = [[self alloc] init];
symbol.name = name;
return symbol;
}
+ (instancetype)symbolWithName:(NSString *)name color:(UIColor *)color {
SCISymbol *symbol = [[self alloc] init];
symbol.name = name;
symbol.color = color;
return symbol;
}
+ (instancetype)symbolWithName:(NSString *)name color:(UIColor *)color size:(CGFloat)size {
SCISymbol *symbol = [[self alloc] init];
symbol.name = name;
symbol.color = color;
symbol.size = size;
return symbol;
}
+ (instancetype)symbolWithName:(NSString *)name color:(UIColor *)color size:(CGFloat)size weight:(UIImageSymbolWeight)weight {
SCISymbol *symbol = [[self alloc] init];
symbol.name = name;
symbol.color = color;
symbol.size = size;
symbol.weight = weight;
return symbol;
}
@end