Sin descripción

KXNewTeachCollectionViewCell.m 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // KXNewTeachCollectionViewCell.m
  3. // CAISHEN
  4. //
  5. // Created by 小花 on 2017/11/8.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "KXNewTeachCollectionViewCell.h"
  9. @interface KXNewTeachCollectionViewCell()
  10. @property (nonatomic, strong) UIImageView *iconImgView;
  11. @property (nonatomic, strong) UILabel *titleLabel;
  12. @end
  13. @implementation KXNewTeachCollectionViewCell
  14. - (instancetype)initWithFrame:(CGRect)frame {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. self.contentView.backgroundColor = [UIColor KXColorWithHex:0xf9f9f9];
  18. [self setUpSubViews];
  19. }
  20. return self;
  21. }
  22. - (void)setUpSubViews {
  23. [self.contentView addSubview:self.iconImgView];
  24. [self.contentView addSubview:self.titleLabel];
  25. [self.iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.centerX.mas_equalTo(self.contentView.mas_centerX);
  27. make.top.mas_offset(Fitsize(20));
  28. make.width.height.mas_equalTo(Fitsize(57));
  29. }];
  30. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.centerX.mas_equalTo(self.iconImgView.mas_centerX);
  32. make.top.mas_equalTo(self.iconImgView.mas_bottom).mas_offset(Fitsize(5));
  33. make.width.mas_equalTo(Fitsize(150));
  34. make.height.mas_equalTo(30);
  35. }];
  36. }
  37. - (void)setTitle:(NSString *)title andImage:(NSString *)imageName {
  38. self.titleLabel.text = title;
  39. self.iconImgView.image = [UIImage imageNamed:imageName];
  40. }
  41. #pragma mark ---------- lazying--------------
  42. - (UIImageView *)iconImgView {
  43. if (!_iconImgView) {
  44. _iconImgView = [[UIImageView alloc] init];
  45. }
  46. return _iconImgView;
  47. }
  48. - (UILabel *)titleLabel {
  49. if (!_titleLabel) {
  50. _titleLabel = [[UILabel alloc] init];
  51. _titleLabel.textAlignment = NSTextAlignmentCenter;
  52. _titleLabel.font = [UIFont systemFontOfSize:Fitsize(13)];
  53. _titleLabel.textColor = [UIColor KXColorWithHex:0xa1a1a1];
  54. }
  55. return _titleLabel;
  56. }
  57. @end