This repository was archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZOECollectionViewCell.m
More file actions
148 lines (131 loc) · 5.1 KB
/
ZOECollectionViewCell.m
File metadata and controls
148 lines (131 loc) · 5.1 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//
// ZOECollectionViewCell.m
// TestCyleImage
//
// Created by zhangwei on 16/4/11.
// Copyright © 2016年 zhangwei. All rights reserved.
//
#import "ZOECollectionViewCell.h"
@interface ZOECollectionViewCell()
@property(nonatomic,strong)UILabel *titleLabel;
@property(nonatomic,strong)UILabel *textLabel;
@property(nonatomic,strong)UILabel *monthLabel;
@property(nonatomic,strong)UILabel *middleMonthLabel;
@property(nonatomic,strong)UIView *cellBackgroundView;
@property(nonatomic,strong)UIView *cellSelectView;
@property(nonatomic,weak)UIView *lineView;
@end
static NSString *const kTitleString = @"预计年化收益";
static inline CGFloat FONTSCALS(CGFloat fontSize){
return [UIScreen mainScreen].bounds.size.width / 375 * fontSize;//5s
}
@implementation ZOECollectionViewCell
-(void)setMonth:(NSString *)month
{
_month = month;
[self.monthLabel setText:_month];
[self.middleMonthLabel setText:self.month];
}
-(void)setTitle:(NSString *)title
{
_title = title;
[self.textLabel setText:_title];
NSString *titleString = @"预计年化收益";
[self.titleLabel setText:titleString];
[self.lineView setHidden: NO];
}
-(void)run
{
[self.cellSelectView setHidden:NO];
[self.textLabel setHidden:NO];
[self.titleLabel setHidden: NO];
[self.monthLabel setHidden: NO];
[self.cellBackgroundView setAlpha:1.0];
[self.middleMonthLabel setHidden:YES];
}
-(void)close
{
[self.cellSelectView setHidden:YES];
[self.textLabel setHidden:YES];
[self.titleLabel setHidden: YES];
[self.monthLabel setHidden: YES];
[self.cellBackgroundView setAlpha:0.5];
[self.middleMonthLabel setHidden:NO];
}
-(void)layoutSubviews
{
[super layoutSubviews];
[self setUpUIView];
}
-(void)setUpUIView
{
// NSLog(@"%@",NSStringFromCGRect(self.contentView.bounds));
self.cellSelectView = [[UIView alloc]initWithFrame:self.contentView.frame];
[self.cellSelectView setBackgroundColor:[UIColor colorWithRed:248 / 255.0 green:109 / 255.0 blue:66 / 255.0 alpha:0.15]];
[self.contentView addSubview: self.cellSelectView];
[self.cellSelectView.layer setCornerRadius:self.cellSelectView.bounds.size.width / 2];
self.cellBackgroundView = [[UIView alloc]initWithFrame:CGRectMake(8, 8, self.contentView.bounds.size.width - 16, self.contentView.bounds.size.height - 16)];
[self.cellBackgroundView setBackgroundColor:[UIColor colorWithRed:248 / 255.0 green:109 / 255.0 blue:66 / 255.0 alpha:1.0f]];
[self.cellBackgroundView.layer setCornerRadius: self.cellBackgroundView.bounds.size.width / 2];
[self.contentView addSubview: self.cellBackgroundView];
[self.cellSelectView setHidden:self.cellSelectViewHide];
[self.contentView addSubview: self.textLabel];
[self.contentView addSubview: self.titleLabel];
[self.contentView addSubview: self.monthLabel];
[self.contentView addSubview: self.middleMonthLabel];
UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, -(FONTSCALS(12)), self.monthLabel.bounds.size.width, 0.5)];
[lineView setBackgroundColor:[UIColor colorWithWhite:255.f alpha:.7]];
[self.monthLabel addSubview:lineView];
self.lineView = lineView;
[self.lineView setHidden: YES];
if (self.cellSelectViewHide) {
[self close];
}else{
[self run];
}
}
#pragma mark - layz
-(UILabel *)textLabel
{
if (_textLabel == nil) {
_textLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, self.contentView.bounds.size.width - 20, 40)];
[_textLabel setTextAlignment:NSTextAlignmentCenter];
[_textLabel setTextColor:[UIColor whiteColor]];
[_textLabel setCenter:self.contentView.center];
[_textLabel setFont:[UIFont systemFontOfSize:FONTSCALS(30)]];
}
return _textLabel;
}
-(UILabel *)titleLabel
{
if (_titleLabel == nil) {
_titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMinY(self.textLabel.frame) - 15, self.contentView.bounds.size.width, 20)];
[_titleLabel setTextAlignment:NSTextAlignmentCenter];
[_titleLabel setTextColor:[UIColor whiteColor]];
[_titleLabel setFont:[UIFont systemFontOfSize: FONTSCALS(11)]];
}
return _titleLabel;
}
-(UILabel *)monthLabel
{
if (_monthLabel == nil) {
CGFloat labelX = 16;
_monthLabel = [[UILabel alloc]initWithFrame:CGRectMake( labelX, self.bounds.size.height - FONTSCALS(35), self.contentView.bounds.size.width - labelX * 2, 20)];
[_monthLabel setTextAlignment:NSTextAlignmentCenter];
[_monthLabel setTextColor:[UIColor whiteColor]];
[_monthLabel setFont:[UIFont systemFontOfSize: FONTSCALS(16)]];
}
return _monthLabel;
}
-(UILabel *)middleMonthLabel
{
if (_middleMonthLabel == nil) {
_middleMonthLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, self.contentView.bounds.size.width - 20, 40)];
[_middleMonthLabel setCenter:self.contentView.center];
[_middleMonthLabel setTextAlignment:NSTextAlignmentCenter];
[_middleMonthLabel setTextColor:[UIColor whiteColor]];
[_middleMonthLabel setFont:[UIFont systemFontOfSize: FONTSCALS(30)]];
}
return _middleMonthLabel;
}
@end