YOUPAILZGameListCell.m 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // YOUPAILZGameListCell.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/4/26.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZGameListCell.h"
  9. #import "YOUPAILZGameModel.h"
  10. @interface YOUPAILZGameListCell ()
  11. @property (nonatomic, weak) UIImageView *youpaipimgV;
  12. @property (nonatomic, weak) UILabel *youpaipnameL;
  13. @property (nonatomic, weak) UIButton *youpaipsetterPriceBtn;
  14. @property (nonatomic, strong) YOUPAILZGameModel *youpaipmodel;
  15. @end
  16. @implementation YOUPAILZGameListCell
  17. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  18. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  19. self.selectionStyle = UITableViewCellSelectionStyleNone;
  20. self.backgroundColor = [UIColor clearColor];
  21. [self youpaifsetupUI];
  22. }
  23. return self;
  24. }
  25. - (void)youpaifsetupUI{
  26. UIView *bgV = [[UIView alloc] init];
  27. bgV.layer.cornerRadius = ScaleSize(8.0f);
  28. bgV.clipsToBounds = YES;
  29. bgV.backgroundColor = [UIColor whiteColor];
  30. [self.contentView addSubview:bgV];
  31. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.top.offset(0.0f);
  33. make.left.offset(ScaleSize(16.0f));
  34. make.right.offset(-ScaleSize(16.0f));
  35. make.bottom.offset(-20.0f);
  36. }];
  37. UIImageView *imgV = [[UIImageView alloc] init];
  38. imgV.contentMode = UIViewContentModeScaleAspectFill;
  39. [bgV addSubview:imgV];
  40. self.youpaipimgV = imgV;
  41. [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.left.top.right.offset(0.0f);
  43. make.height.offset(ScaleSize(193.0f));
  44. }];
  45. UILabel *nameL = [[UILabel alloc] init];
  46. nameL.textAlignment = NSTextAlignmentCenter;
  47. nameL.font = LCFont17;
  48. nameL.textColor = HexColorFromRGB(0x333333);
  49. [bgV addSubview:nameL];
  50. self.youpaipnameL = nameL;
  51. [nameL mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.top.equalTo(imgV.mas_bottom).offset(0.0f);
  53. make.left.bottom.right.offset(0.0f);
  54. }];
  55. UIButton *setterPriceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  56. [setterPriceBtn setTitle:@"设置价格" forState:UIControlStateNormal];
  57. [setterPriceBtn setTitleColor:ZYPinkColor forState:UIControlStateNormal];
  58. setterPriceBtn.titleLabel.font = LCFont15;
  59. // [setterPriceBtn setImage:[UIImage imageNamed:@"vqu_images_game_setter_price"] forState:UIControlStateNormal];
  60. [setterPriceBtn addTarget:self action:@selector(youpaifsetterPriceBtnClick) forControlEvents:UIControlEventTouchUpInside];
  61. [bgV addSubview:setterPriceBtn];
  62. self.youpaipsetterPriceBtn = setterPriceBtn;
  63. [setterPriceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.top.equalTo(imgV.mas_bottom).offset(0.0f);
  65. make.right.offset(-10.0f);
  66. make.bottom.offset(0.0f);
  67. // make.width.offset(49.0f);
  68. }];
  69. setterPriceBtn.hidden = YES;
  70. }
  71. - (void)youpaifreloadWithModel:(YOUPAILZGameModel *)model{
  72. self.youpaipmodel = model;
  73. [self.youpaipimgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipcover]];
  74. self.youpaipnameL.text = model.youpaipname;
  75. self.youpaipsetterPriceBtn.hidden = model.youpaipprice == -1;
  76. }
  77. - (void)youpaifsetterPriceBtnClick{
  78. if (self.setterPriceBtnClickBlock != nil) {
  79. self.setterPriceBtnClickBlock(self.youpaipmodel);
  80. }
  81. }
  82. @end