线上所有马甲包模板,与《猎豆》同UI。域名zhuadd

HSQContainerImageCell.m 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // HSQContainerImageCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/12/28.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "HSQContainerImageCell.h"
  9. @interface HSQContainerImageCell ()
  10. @property (nonatomic, strong) UIImageView *imgView;
  11. @property (nonatomic, strong) UIButton *selectedBtn;
  12. @end
  13. @implementation HSQContainerImageCell
  14. - (instancetype)initWithFrame:(CGRect)frame
  15. {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. [self initSubViews];
  19. }
  20. return self;
  21. }
  22. - (void)initSubViews {
  23. [self.contentView addSubview:self.imgView];
  24. [self.contentView addSubview:self.selectedBtn];
  25. [self.contentView addSubview:self.qrImgLabel];
  26. [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
  28. }];
  29. [self.selectedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.top.right.mas_equalTo(0);
  31. make.width.height.mas_equalTo(40);
  32. }];
  33. [self.qrImgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.left.right.bottom.mas_equalTo(0);
  35. make.height.mas_equalTo(28);
  36. }];
  37. }
  38. - (void)selectAction {
  39. if (self.selectBlock) {
  40. self.selectBlock();
  41. }
  42. }
  43. - (void)setModel:(HSQShareImageCellModel *)model {
  44. if (model.imgUrl) {
  45. [self.imgView sd_setFadeImageWithURL:[NSURL URLWithString:model.imgUrl] placeholderImage:nil options:0 progress:nil completed:nil];
  46. }else {
  47. if (model.shareImg) {
  48. self.imgView.image = model.shareImg;
  49. }else {
  50. self.imgView.image = nil;
  51. }
  52. }
  53. self.selectedBtn.selected = model.isSelected;
  54. }
  55. - (UIImageView *)imgView {
  56. if (!_imgView) {
  57. _imgView = [[UIImageView alloc] init];
  58. _imgView.contentMode = UIViewContentModeScaleAspectFit;
  59. _imgView.backgroundColor = [UIColor whiteColor];
  60. }
  61. return _imgView;
  62. }
  63. - (UIButton *)selectedBtn {
  64. if (!_selectedBtn) {
  65. _selectedBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  66. [_selectedBtn setImage:[UIImage imageNamed:@"cell_sel_n"] forState:UIControlStateNormal];
  67. [_selectedBtn setImage:[UIImage imageNamed:@"cell_sel_s"] forState:UIControlStateSelected];
  68. [_selectedBtn addTarget:self action:@selector(selectAction) forControlEvents:UIControlEventTouchUpInside];
  69. }
  70. return _selectedBtn;
  71. }
  72. - (UILabel *)qrImgLabel {
  73. if (!_qrImgLabel) {
  74. _qrImgLabel = [[UILabel alloc] init];
  75. _qrImgLabel.backgroundColor = [UIColor YHColorWithHex:0xFF891A];
  76. _qrImgLabel.textColor = [UIColor whiteColor];
  77. _qrImgLabel.textAlignment = NSTextAlignmentCenter;
  78. _qrImgLabel.font = [UIFont systemFontOfSize:13];
  79. _qrImgLabel.text = @"二维码推广图";
  80. }
  81. return _qrImgLabel;
  82. }
  83. @end