猎豆优选

LDMenuCollectionCell.m 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // LDMenuCollectionCell.m
  3. // YouHuiProject
  4. //
  5. // Created by liuxueli on 2019/1/17.
  6. // Copyright © 2019 kuxuan. All rights reserved.
  7. //
  8. #import "LDMenuCollectionCell.h"
  9. @implementation LDMenuCollectionCell
  10. - (instancetype)initWithFrame:(CGRect)frame {
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. [self addSubview:self.iconimgV];
  14. [self addSubview:self.titleLabel];
  15. [self addSubview:self.redlabel];
  16. CGFloat heights= (self.width-45)/2;
  17. [self.iconimgV mas_makeConstraints:^(MASConstraintMaker *make) {
  18. make.width.mas_equalTo(22);
  19. make.height.mas_equalTo(22);
  20. make.top.mas_equalTo(FITSIZE(heights));
  21. make.centerX.mas_equalTo(self.mas_centerX);
  22. }];
  23. [self.redlabel mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.width.height.mas_equalTo(10);
  25. make.left.mas_equalTo(self.iconimgV.mas_right).offset(2);
  26. make.top.mas_equalTo(self.iconimgV.mas_top).offset(-5);
  27. }];
  28. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.top.mas_equalTo(self.iconimgV.mas_bottom).offset(14);
  30. make.width.mas_equalTo(self.width);
  31. }];
  32. }
  33. return self;
  34. }
  35. -(void)setModel:(LDMineToolModel *)model
  36. {
  37. _model = model;
  38. [self.iconimgV sd_setImageWithURL:[NSURL URLWithString:model.icon]];
  39. self.titleLabel.text=model.title;
  40. if (model.show_spot.integerValue == 1) {
  41. self.redlabel.hidden=NO;
  42. }else{
  43. self.redlabel.hidden=YES;
  44. }
  45. }
  46. -(UIImageView *)iconimgV
  47. {
  48. if (!_iconimgV) {
  49. _iconimgV =[[UIImageView alloc]init];
  50. _iconimgV.image=[UIImage imageNamed:@"placeHolder"];
  51. }
  52. return _iconimgV;
  53. }
  54. -(UILabel *)titleLabel
  55. {
  56. if (!_titleLabel) {
  57. _titleLabel =[[UILabel alloc]init];
  58. _titleLabel.textColor=[UIColor YHColorWithHex:0x7c7c7c];
  59. _titleLabel.font=[UIFont systemFontOfSize:12];
  60. _titleLabel.textAlignment=NSTextAlignmentCenter;
  61. }
  62. return _titleLabel;
  63. }
  64. -(UILabel *)redlabel
  65. {
  66. if (!_redlabel) {
  67. _redlabel =[[UILabel alloc]init];
  68. _redlabel.font=[UIFont systemFontOfSize:9];
  69. _redlabel.backgroundColor=[UIColor colorWithRed:250/255.0 green:44/255.0 blue:54/255.0 alpha:1.0];
  70. // _redlabel.text=@"拆";
  71. _redlabel.textColor=[UIColor whiteColor];
  72. _redlabel.layer.cornerRadius=5;
  73. _redlabel.hidden=YES;
  74. _redlabel.layer.masksToBounds=YES;
  75. _redlabel.textAlignment=NSTextAlignmentCenter;
  76. }
  77. return _redlabel;
  78. }
  79. @end