StudentDetailInfoCell.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // StudentDetailInfoCell.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/25.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "StudentDetailInfoCell.h"
  9. #import "StudentDetailInfoModel.h"
  10. @interface StudentDetailInfoCell ()
  11. @property (nonatomic, readwrite, strong) UILabel *titleLabel;
  12. @property (nonatomic, readwrite, strong) UILabel *contentLabel;
  13. @end
  14. @implementation StudentDetailInfoCell
  15. #pragma mark - Life Cycle
  16. - (instancetype)initWithFrame:(CGRect)frame {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. self.contentView.backgroundColor = UIColor.whiteColor;
  20. [self.contentView addSubview:self.titleLabel];
  21. [self.contentView addSubview:self.contentLabel];
  22. }
  23. __weak typeof(self) weakS = self;
  24. [self addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
  25. [weakS clickSelf];
  26. }];
  27. return self;
  28. }
  29. - (void)layoutSubviews {
  30. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.mas_offset(16);
  32. make.centerY.mas_equalTo(self.contentView);
  33. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (3 * 16)) / 3.0, self.bounds.size.height));
  34. }];
  35. [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(_titleLabel.mas_right).mas_offset(16);
  37. make.centerY.mas_equalTo(self.contentView);
  38. make.size.mas_equalTo(CGSizeMake((2 * (self.bounds.size.width - (3 * 16))) / 3.0, self.bounds.size.height));
  39. }];
  40. [super layoutSubviews];
  41. }
  42. #pragma mark - Private Functions
  43. - (void)updateCellUI:(__kindof HDCellModel *)model {
  44. if ([model.orgData isKindOfClass:[StudentDetailInfoModel class]]) {
  45. StudentDetailInfoModel *studentDetailInfoModel = model.orgData;
  46. self.titleLabel.text = studentDetailInfoModel.titleString;
  47. self.contentLabel.text = studentDetailInfoModel.contentString;
  48. }
  49. }
  50. - (void)clickSelf {
  51. self.callback(self.hdModel);
  52. }
  53. #pragma mark - Lazy Load
  54. - (UILabel *)titleLabel {
  55. if (!_titleLabel) {
  56. _titleLabel = [[UILabel alloc] init];
  57. _titleLabel.numberOfLines = 0;
  58. _titleLabel.font = [UIFont systemFontOfSize:15];
  59. _titleLabel.textColor = RQTitleTextColor;
  60. }
  61. return _titleLabel;
  62. }
  63. - (UILabel *)contentLabel {
  64. if (!_contentLabel) {
  65. _contentLabel = [[UILabel alloc] init];
  66. _contentLabel.numberOfLines = 0;
  67. _contentLabel.font = [UIFont systemFontOfSize:15];
  68. _contentLabel.textColor = RQContentTextColor;
  69. }
  70. return _contentLabel;
  71. }
  72. @end