Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
60 lines (49 loc) · 1.64 KB

File metadata and controls

60 lines (49 loc) · 1.64 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
//
// ProjectTagLabel.m
// Coding_iOS
//
// Created by Ease on 15/7/21.
// Copyright (c) 2015年 Coding. All rights reserved.
//
#import "ProjectTagLabel.h"
@interface ProjectTagLabel ()
@property (assign, nonatomic) CGFloat height, width_padding;
@end
@implementation ProjectTagLabel
- (instancetype)init
{
self = [super init];
if (self) {
self.textAlignment = NSTextAlignmentCenter;
self.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
self.layer.cornerRadius = 2;
_height = 20;
_width_padding = 10;
}
return self;
}
- (void)setCurTag:(ProjectTag *)curTag{
_curTag = curTag;
[self setup];
}
+ (instancetype)labelWithTag:(ProjectTag *)curTag font:(UIFont *)font height:(CGFloat)height widthPadding:(CGFloat)width_padding{
ProjectTagLabel *label = [self new];
label.font = font;
label.height = height;
label.width_padding = width_padding;
label.curTag = curTag;
return label;
}
- (void)setup{
if (!self.curTag || self.curTag.name.length <= 0) {
[self setSize:CGSizeZero];
return;
}
UIColor *tagColor = self.curTag.color.length > 1? [UIColor colorWithHexString:[self.curTag.color stringByReplacingOccurrencesOfString:@"#" withString:@"0x"]]: kColorBrandGreen;
self.layer.backgroundColor = tagColor.CGColor;
self.textColor = [tagColor isDark]? [UIColor whiteColor]: [UIColor blackColor];
CGFloat selfWidth = [self.curTag.name getWidthWithFont:self.font constrainedToSize:CGSizeMake(CGFLOAT_MAX, _height)] + _width_padding;
[self setSize:CGSizeMake(selfWidth, _height)];
self.text = self.curTag.name;
}
@end
Morty Proxy This is a proxified and sanitized view of the page, visit original site.