FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Coding-iOS/Coding_iOS/Views/ActivityMonScrollView.m at master · feihuohua/Coding-iOS · GitHub
feihuohua
/
Coding-iOS
Public
forked from
coding/Coding-iOS
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Views
/
ActivityMonScrollView.m
Copy path
More file actions
More file actions
Latest commit
History
History
History
108 lines (84 loc) · 3.15 KB
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Views
/
ActivityMonScrollView.m
Copy path
File metadata and controls
108 lines (84 loc) · 3.15 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//
//
ActivityMonScrollView.m
//
Coding_iOS
//
//
Created by 张达棣 on 16/11/29.
//
Copyright © 2016年 Coding. All rights reserved.
//
#
import
"
ActivityMonScrollView.h
"
#
import
"
ActivityView.h
"
#
define
KMon
12
@interface
ActivityMonScrollView
()
@property
(
nonatomic
,
strong
) ActivityView *activityView;
@property
(
nonatomic
,
strong
)
NSMutableArray
*monLabelArray;
@end
@implementation
ActivityMonScrollView
#
pragma mark
- 生命周期方法
- (
void
)
awakeFromNib
{
[
super
awakeFromNib
];
[
self
creatView
];
}
- (
instancetype
)
init
{
self = [
super
init
];
if
(self) {
[
self
creatView
];
}
return
self;
}
#
pragma mark
- 外部方法
#
pragma
makr - 消息
#
pragma mark
- 系统委托
#
pragma mark
- 自定义委托
#
pragma mark
- 响应方法
#
pragma mark
- 私有方法
- (
void
)
creatView
{
self.
showsHorizontalScrollIndicator
=
NO
;
_activityView = [[ActivityView
alloc
]
init
];
[
self
addSubview:
_activityView];
[
self
setupAutoContentSizeWithRightView:
_activityView
rightMargin:
15
];
self.
monLabelArray
= [
NSMutableArray
arrayWithCapacity:
KMon];
for
(
int
i =
0
; i < KMon; i++) {
UILabel *label = [[UILabel
alloc
]
init
];
label.
textColor
= [UIColor
colorWithRGBHex:
0x666666
];
label.
font
= [UIFont
systemFontOfSize:
12
];
[
self
addSubview:
label];
label.
sd_layout
.
leftSpaceToView
(self,
22
+ i *
48
).
topSpaceToView
(self,
0
).
heightIs
(
17
).
widthIs
(
24
);
[_monLabelArray
addObject:
label];
}
}
#
pragma mark
- get/set方法
- (
void
)
setDailyActiveness
:
(
NSArray
<DailyActiveness *> *)
dailyActiveness
{
_dailyActiveness = dailyActiveness;
NSMutableArray
*colorArray = [
NSMutableArray
array
];
for
(DailyActiveness *item in dailyActiveness) {
UIColor *color;
if
(item.
count
.
integerValue
==
0
) {
color = [UIColor
colorWithRGBHex:
0xeeeeee
];
}
else
if
(
1
<= item.
count
.
integerValue
&& item.
count
.
integerValue
<=
24
) {
color = [UIColor
colorWithRGBHex:
0xd6e685
];
}
else
if
(
25
<= item.
count
.
integerValue
&& item.
count
.
integerValue
<=
49
) {
color = [UIColor
colorWithRGBHex:
0x8cc665
];
}
else
if
(
50
<= item.
count
.
integerValue
&& item.
count
.
integerValue
<=
74
) {
color = [UIColor
colorWithRGBHex:
0x44a340
];
}
else
if
(
75
<= item.
count
.
integerValue
) {
color = [UIColor
colorWithRGBHex:
0x1e6923
];
}
[colorArray
addObject:
color];
}
_activityView.
colorArray
= colorArray;
NSInteger
row = colorArray.
count
/
7
;
if
(colorArray.
count
%
7
!=
0
) {
row++;
}
_activityView.
sd_layout
.
leftSpaceToView
(self,
0
).
topSpaceToView
(self,
22
).
heightIs
(
77
).
widthIs
(row *
11
);
}
- (
void
)
setStartMon
:
(
NSInteger
)
startMon
{
_startMon = startMon;
NSArray
*monArray = @[
@"
Dec
"
,
@"
Jan
"
,
@"
Feb
"
,
@"
Mar
"
,
@"
Apr
"
,
@"
May
"
,
@"
Jun
"
,
@"
Jul
"
,
@"
Aug
"
,
@"
Sep
"
,
@"
Oct
"
,
@"
Nov
"
];
for
(
NSInteger
i = _startMon; i < _startMon + KMon; i++) {
NSString
*mon = monArray[(i +
1
) % KMon];
//
UI 元素的位置是下个月开始的位置,所以月份也显示成下个月
UILabel *label = _monLabelArray[i - _startMon];
label.
text
= mon;
}
}
@end
Back
|
FazBrowse Home
|
New Git URL