XYSkillCertificationApplyBoxView.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // XYSkillCertificationApplyBoxView.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/10/26.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYSkillCertificationApplyBoxView.h"
  9. @interface XYSkillCertificationApplyBoxView ()
  10. @property (nonatomic, strong) UIImageView *moreImageView;
  11. @property (nonatomic, strong) UIButton *actionButton;
  12. @property (nonatomic, strong) UIView *line;
  13. @end
  14. @implementation XYSkillCertificationApplyBoxView
  15. - (instancetype)initWithFrame:(CGRect)frame
  16. {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. [self setupUI];
  20. }
  21. return self;
  22. }
  23. #pragma mark — UI
  24. - (void)setupUI {
  25. [self addSubview:self.titleLabel];
  26. [self addSubview:self.contentLabel];
  27. [self addSubview:self.moreImageView];
  28. [self addSubview:self.actionButton];
  29. [self addSubview:self.line];
  30. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.equalTo(self).offset(20.0f);
  32. make.centerY.equalTo(self);
  33. }];
  34. [self.moreImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.right.equalTo(self).offset(-20.0f);
  36. make.centerY.equalTo(self);
  37. make.width.height.equalTo(@18.0f);
  38. }];
  39. [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.right.equalTo(self.moreImageView.mas_left);
  41. make.centerY.equalTo(self);
  42. make.left.greaterThanOrEqualTo(self.titleLabel.mas_right).offset(10.0f);
  43. }];
  44. [self.actionButton mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.edges.equalTo(self);
  46. }];
  47. [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.right.bottom.equalTo(self);
  49. make.height.equalTo(@0.55f);
  50. }];
  51. }
  52. - (void)actionButton:(id)sender {
  53. if (self.actionBlock) {
  54. self.actionBlock();
  55. }
  56. }
  57. #pragma mark — Getter
  58. - (UILabel *)titleLabel {
  59. if (!_titleLabel) {
  60. _titleLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font(14)];
  61. }
  62. return _titleLabel;
  63. }
  64. - (UILabel *)contentLabel {
  65. if (!_contentLabel) {
  66. _contentLabel = [UILabel createLabelTextColor:Color_TextGray fount:Font_B(14)];
  67. _contentLabel.textAlignment = NSTextAlignmentRight;
  68. }
  69. return _contentLabel;
  70. }
  71. - (UIImageView *)moreImageView {
  72. if (!_moreImageView) {
  73. _moreImageView = [UIImageView new];
  74. _moreImageView.image = ImageNamed(@"apply_more");
  75. }
  76. return _moreImageView;
  77. }
  78. - (UIButton *)actionButton {
  79. if (!_actionButton) {
  80. _actionButton = [UIButton buttonWithType:UIButtonTypeCustom];
  81. _actionButton.backgroundColor = Color_Clear;
  82. [_actionButton addTarget:self action:@selector(actionButton:) forControlEvents:UIControlEventTouchUpInside];
  83. }
  84. return _actionButton;
  85. }
  86. - (UIView *)line {
  87. if (!_line) {
  88. _line = [UIView new];
  89. _line.backgroundColor = Color_line;
  90. }
  91. return _line;
  92. }
  93. @end