123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- //
- // HSQDateHeaderView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/1/24.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "HSQDateHeaderView.h"
- @interface HSQDateHeaderView()
- @property (nonatomic, strong) UIView *leftLine;
- @property (nonatomic, strong) UIView *rightLine;
- @property (nonatomic, strong) UIView *leftCircle;
- @property (nonatomic, strong) UIView *rightCircle;
- @property (nonatomic, strong) UILabel *titleLabel;
- @end
- @implementation HSQDateHeaderView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor whiteColor];
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- [self addSubview:self.leftLine];
- [self addSubview:self.leftCircle];
- [self addSubview:self.titleLabel];
- [self addSubview:self.rightCircle];
- [self addSubview:self.rightLine];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(self.mas_centerX);
- make.centerY.mas_equalTo(self.mas_centerY);
- make.height.mas_equalTo(40);
- }];
-
- [self.leftCircle mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
- make.right.mas_equalTo(self.titleLabel.mas_left).mas_offset(-5);
- make.width.height.mas_equalTo(4);
- }];
-
- [self.leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(self.leftCircle.mas_left).mas_offset(-5);
- make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
- make.width.mas_equalTo(60);
- make.height.mas_equalTo(1);
- }];
-
- [self.rightCircle mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
- make.left.mas_equalTo(self.titleLabel.mas_right).mas_offset(5);
- make.width.height.mas_equalTo(4);
- }];
-
- [self.rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.rightCircle.mas_right).mas_offset(5);
- make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
- make.width.mas_equalTo(60);
- make.height.mas_equalTo(1);
- }];
-
- }
- - (void)setDateWith:(NSString *)dateStr {
- self.titleLabel.text = dateStr;
- }
- #pragma mark ------
- - (UIView *)leftLine {
- if (!_leftLine) {
- _leftLine = [[UIView alloc] init];
- _leftLine.backgroundColor = [UIColor YHColorWithHex:0xdddddd];
- }
- return _leftLine;
- }
- - (UIView *)rightLine {
- if (!_rightLine) {
- _rightLine = [[UIView alloc] init];
- _rightLine.backgroundColor = [UIColor YHColorWithHex:0xdddddd];
- }
- return _rightLine;
- }
- - (UIView *)leftCircle {
- if (!_leftCircle) {
- _leftCircle = [[UIView alloc] init];
- _leftCircle.backgroundColor = [UIColor YHColorWithHex:0xd7d7d7];
- _leftCircle.layer.cornerRadius = 2;
- }
- return _leftCircle;
- }
- - (UIView *)rightCircle {
- if (!_rightCircle) {
- _rightCircle = [[UIView alloc] init];
- _rightCircle.backgroundColor = [UIColor YHColorWithHex:0xd7d7d7];
- _rightCircle.layer.cornerRadius = 2;
- }
- return _rightCircle;
- }
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [[UILabel alloc] init];
- _titleLabel.textColor = [UIColor YHColorWithHex:0x666666];
- _titleLabel.font = [UIFont systemFontOfSize:13];
- _titleLabel.textAlignment = NSTextAlignmentCenter;
- _titleLabel.text = @"1月1日";
- }
- return _titleLabel;
- }
- @end
|