new_bgmcategoryCell.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // new_bgmcategoryCell.m
  3. // BuguLive
  4. //
  5. // Created by bugu on 2019/5/25.
  6. // Copyright © 2019年 xfg. All rights reserved.
  7. //
  8. #import "new_bgmcategoryCell.h"
  9. @implementation new_bgmcategoryModel
  10. @end
  11. @implementation new_bgmcategoryCell
  12. {
  13. UIImageView *icon;
  14. UILabel *titleLa;
  15. }
  16. - (instancetype)initWithFrame:(CGRect)frame
  17. {
  18. self =[super initWithFrame:frame];
  19. [self drawsubviews];
  20. return self;
  21. }
  22. -(void)setModel:(new_bgmcategoryModel *)model
  23. {
  24. _model =model;
  25. [icon sd_setImageWithURL:[NSURL URLWithString:model.icon]];
  26. titleLa.text =model.type_name;
  27. }
  28. - (void)drawsubviews
  29. {
  30. if (!icon)
  31. {
  32. __weak typeof(self)weakself =self;
  33. icon =[[UIImageView alloc]init];
  34. [self addSubview:icon];
  35. [icon mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.width.centerX.equalTo(weakself);
  37. make.height.equalTo(@(60));
  38. make.bottom.equalTo(weakself.mas_centerY);
  39. }];
  40. icon.contentMode =UIViewContentModeScaleAspectFit;
  41. titleLa =[[UILabel alloc]init];
  42. [self addSubview:titleLa];
  43. [titleLa mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.top.equalTo(weakself.mas_centerY).offset(10);
  45. make.width.centerX.equalTo(weakself);
  46. make.height.equalTo(@16.);
  47. }];
  48. titleLa.font = [UIFont systemFontOfSize:14.];
  49. titleLa.textColor =kBlackColor;
  50. titleLa.textAlignment =1;
  51. }
  52. }
  53. @end