FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Coding-iOS/Coding_iOS/Views/ProjectTagLabel.m at master · MFunZero/Coding-iOS · GitHub
MFunZero
/
Coding-iOS
Public
forked from
coding/Coding-iOS
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Views
/
ProjectTagLabel.m
Copy path
More file actions
More file actions
Latest commit
History
History
History
60 lines (49 loc) · 1.64 KB
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Views
/
ProjectTagLabel.m
Copy path
File metadata and controls
60 lines (49 loc) · 1.64 KB
Raw
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
Back
|
FazBrowse Home
|
New Git URL