StudentDetailSecOneCell.m 2.2 KB

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