MOSelectPartitionCell.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // MOSelectPartitionCell.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/10/16.
  6. //
  7. #import "MOSelectPartitionCell.h"
  8. @implementation MOSelectPartitionCell
  9. #pragma mark - View Cycle
  10. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  11. {
  12. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  13. self.selectionStyle = UITableViewCellSelectionStyleNone;
  14. self.backgroundColor = [UIColor whiteColor];
  15. _iconImg = [UIImageView new];
  16. [self.contentView addSubview:_iconImg];
  17. [_iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
  18. make.left.equalTo(self.contentView).offset(16.0);
  19. make.centerY.equalTo(self.contentView).offset(0);
  20. make.width.equalTo(@(24.0));
  21. make.height.equalTo(@(24.0));
  22. }];
  23. _titleLab = [UILabel new];
  24. _titleLab.textColor = [MOTools colorWithHexString:@"#000000" alpha:1.0];
  25. _titleLab.textAlignment = NSTextAlignmentLeft;
  26. _titleLab.font = [MOTextTools poppinsRegularFont:16];
  27. [self.contentView addSubview:_titleLab];
  28. [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.left.equalTo(self.iconImg.mas_right).offset(12.0);
  30. make.centerY.equalTo(self.contentView).offset(0);
  31. make.width.greaterThanOrEqualTo(@55.0);
  32. make.height.equalTo(@(22.0));
  33. }];
  34. _numLab = [UILabel new];
  35. _numLab.textColor = kBaseTextColor_1;
  36. _numLab.textAlignment = NSTextAlignmentLeft;
  37. _numLab.font = [MOTextTools poppinsRegularFont:16];
  38. [self.contentView addSubview:_numLab];
  39. [_numLab mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.equalTo(self.titleLab.mas_right).offset(5);
  41. make.centerY.equalTo(self.contentView).offset(0);
  42. make.width.greaterThanOrEqualTo(@39.0);
  43. make.height.equalTo(@(22.0));
  44. }];
  45. // UIView *lineView = [[UIView alloc] init];
  46. // lineView.backgroundColor = [MOTools colorWithHexString:@"#E5E5E5" alpha:0.3];
  47. // [self.contentView addSubview:lineView];
  48. // [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  49. // make.left.equalTo(self.contentView).offset(12.0);
  50. // make.right.equalTo(self.contentView).offset(-18.0);
  51. // make.height.mas_equalTo(1);
  52. // make.bottom.equalTo(self.contentView);
  53. // }];
  54. }
  55. return self;
  56. }
  57. - (void)setModel:(MOCountryList *)model{
  58. _model = model;
  59. __weak typeof(self) weakSelf = self;
  60. [self.iconImg sd_setImageWithURL:[NSURL URLWithString:model.icon2] placeholderImage:[UIImage imageNamed:@""] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  61. __strong typeof(self) strongSelf = weakSelf;
  62. if (!strongSelf) return;
  63. if (!image) return;
  64. // [strongSelf.iconImg mas_updateConstraints:^(MASConstraintMaker *make) {
  65. // make.width.equalTo(@(image.size.width * 20.0 / image.size.height));
  66. // }];
  67. }];
  68. self.titleLab.text = model.name;
  69. self.numLab.text = model.num;
  70. }
  71. - (void)awakeFromNib {
  72. [super awakeFromNib];
  73. // Initialization code
  74. }
  75. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  76. [super setSelected:selected animated:animated];
  77. // Configure the view for the selected state
  78. }
  79. @end