CommodityCell3.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // CommodityCell3.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/3/3.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "CommodityCell3.h"
  9. @implementation CommodityCell3
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. // Initialization code
  13. }
  14. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  15. [super setSelected:selected animated:animated];
  16. // Configure the view for the selected state
  17. }
  18. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  19. {
  20. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  21. if (self) {
  22. [self createUI];
  23. }
  24. return self;
  25. }
  26. -(void)createUI{
  27. _headImg = [[UIImageView alloc]init];
  28. _headImg.frame = CGRectMake(15, 10, 50, 50);
  29. _headImg.backgroundColor = [UIColor lightGrayColor];
  30. _headImg.layer.cornerRadius = 25;
  31. _headImg.layer.masksToBounds = YES;
  32. [self.contentView addSubview:_headImg];
  33. _nameLb = [[UILabel alloc]init];
  34. _nameLb.frame = CGRectMake(_headImg.right+10, 0, 150, 20);
  35. _nameLb.centerY = _headImg.centerY;
  36. _nameLb.textColor = [UIColor blackColor];
  37. _nameLb.font = [UIFont systemFontOfSize:14];
  38. [self.contentView addSubview:_nameLb];
  39. UIButton *goshopBtn = [UIButton buttonWithType:0];
  40. goshopBtn.frame = CGRectMake(_window_width-90, 0, 80, 18);
  41. goshopBtn.centerY = _headImg.centerY;
  42. [goshopBtn setTitleColor:Pink_Cor forState:0];
  43. [goshopBtn setTitle:YZMsg(@"进店逛逛") forState:0];
  44. goshopBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
  45. [goshopBtn setImage:[UIImage imageNamed:@"shop_right_normal"] forState:0];
  46. goshopBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  47. [goshopBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, - goshopBtn.imageView.image.size.width, 0, goshopBtn.imageView.image.size.width)];
  48. [goshopBtn setImageEdgeInsets:UIEdgeInsetsMake(0, goshopBtn.titleLabel.bounds.size.width, 0, -goshopBtn.titleLabel.bounds.size.width)];
  49. [goshopBtn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
  50. [self.contentView addSubview:goshopBtn];
  51. _infoView = [[StoreInfoView alloc]initWithFrame:CGRectMake(15, _headImg.bottom +15, _window_width-30, 64)];
  52. [self addSubview:_infoView];
  53. }
  54. -(void)setModel:(CommodityDetailModel *)model
  55. {
  56. _model = model;
  57. [_headImg sd_setImageWithURL:[NSURL URLWithString:_model.shop_avatar]];
  58. _nameLb.text = model.shop_name;
  59. _infoView.storeModels = model;
  60. }
  61. -(void)btnClick{
  62. [self.delegate goshopClick];
  63. }
  64. @end