《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRDateHeaderView.m 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // DRDateHeaderView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/1/24.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRDateHeaderView.h"
  9. @interface DRDateHeaderView()
  10. @property (nonatomic, strong) UIView *leftLine;
  11. @property (nonatomic, strong) UIView *rightLine;
  12. @property (nonatomic, strong) UIView *leftCircle;
  13. @property (nonatomic, strong) UIView *rightCircle;
  14. @property (nonatomic, strong) UILabel *titleLabel;
  15. @end
  16. @implementation DRDateHeaderView
  17. - (instancetype)initWithFrame:(CGRect)frame {
  18. self = [super initWithFrame:frame];
  19. if (self) {
  20. self.backgroundColor = [UIColor whiteColor];
  21. [self initSubViews];
  22. }
  23. return self;
  24. }
  25. - (void)initSubViews {
  26. [self addSubview:self.leftLine];
  27. [self addSubview:self.leftCircle];
  28. [self addSubview:self.titleLabel];
  29. [self addSubview:self.rightCircle];
  30. [self addSubview:self.rightLine];
  31. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.centerX.mas_equalTo(self.mas_centerX);
  33. make.centerY.mas_equalTo(self.mas_centerY);
  34. make.height.mas_equalTo(40);
  35. }];
  36. [self.leftCircle mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  38. make.right.mas_equalTo(self.titleLabel.mas_left).mas_offset(-5);
  39. make.width.height.mas_equalTo(4);
  40. }];
  41. [self.leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.right.mas_equalTo(self.leftCircle.mas_left).mas_offset(-5);
  43. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  44. make.width.mas_equalTo(60);
  45. make.height.mas_equalTo(1);
  46. }];
  47. [self.rightCircle mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  49. make.left.mas_equalTo(self.titleLabel.mas_right).mas_offset(5);
  50. make.width.height.mas_equalTo(4);
  51. }];
  52. [self.rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.mas_equalTo(self.rightCircle.mas_right).mas_offset(5);
  54. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  55. make.width.mas_equalTo(60);
  56. make.height.mas_equalTo(1);
  57. }];
  58. }
  59. - (void)setDateWith:(NSString *)dateStr {
  60. self.titleLabel.text = dateStr;
  61. }
  62. #pragma mark ------
  63. - (UIView *)leftLine {
  64. if (!_leftLine) {
  65. _leftLine = [[UIView alloc] init];
  66. _leftLine.backgroundColor = [UIColor YHColorWithHex:0xdddddd];
  67. }
  68. return _leftLine;
  69. }
  70. - (UIView *)rightLine {
  71. if (!_rightLine) {
  72. _rightLine = [[UIView alloc] init];
  73. _rightLine.backgroundColor = [UIColor YHColorWithHex:0xdddddd];
  74. }
  75. return _rightLine;
  76. }
  77. - (UIView *)leftCircle {
  78. if (!_leftCircle) {
  79. _leftCircle = [[UIView alloc] init];
  80. _leftCircle.backgroundColor = [UIColor YHColorWithHex:0xd7d7d7];
  81. _leftCircle.layer.cornerRadius = 2;
  82. }
  83. return _leftCircle;
  84. }
  85. - (UIView *)rightCircle {
  86. if (!_rightCircle) {
  87. _rightCircle = [[UIView alloc] init];
  88. _rightCircle.backgroundColor = [UIColor YHColorWithHex:0xd7d7d7];
  89. _rightCircle.layer.cornerRadius = 2;
  90. }
  91. return _rightCircle;
  92. }
  93. - (UILabel *)titleLabel {
  94. if (!_titleLabel) {
  95. _titleLabel = [[UILabel alloc] init];
  96. _titleLabel.textColor = [UIColor YHColorWithHex:0x666666];
  97. _titleLabel.font = [UIFont systemFontOfSize:13];
  98. _titleLabel.textAlignment = NSTextAlignmentCenter;
  99. _titleLabel.text = @"1月1日";
  100. }
  101. return _titleLabel;
  102. }
  103. @end