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
//
// TriangleIndicatorView.m
// Lighting
//
// Created by 曹云霄 on 2017/3/15.
// Copyright © 2017年 上海勾芒科技有限公司. All rights reserved.
//
#import "TriangleIndicatorView.h"
@implementation TriangleIndicatorView
- (instancetype)initializeView:(CGRect)frame contentLabel:(NSString *)year;
{
if (self == [super initWithFrame:frame]) {
UIImageView *imageView = [[UIImageView alloc] init];
imageView.image = TCImage(@"triangle");
[self addSubview:imageView];
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.bottom.equalTo(self);
}];
UILabel *label = [[UILabel alloc] init];
label.text = year;
label.textColor = [UIColor whiteColor];
label.font = [UIFont systemFontOfSize:6];
label.textAlignment = NSTextAlignmentCenter;
[label sizeToFit];
[self addSubview:label];
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.mas_bottom);
make.left.right.equalTo(self);
make.height.mas_equalTo(self.height*0.5);
}];
}
return self;
}
- (void)setYearString:(NSString *)yearString
{
for (id object in self.subviews) {
if ([object isKindOfClass:[UILabel class]]) {
UILabel *label = (UILabel *)object;
label.text = yearString;break;
}
}
}
@end