口袋优选

KBMyCoupleHeader.m 4.0KB

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