filePathCreatTableViewCell.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. //
  2. // filePathCreatTableViewCell.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/12/29.
  6. //
  7. #import "filePathCreatTableViewCell.h"
  8. @implementation filePathCreatTableViewCell
  9. @synthesize cellBgView;
  10. @synthesize mImageView;
  11. @synthesize titleLabel;
  12. @synthesize titleLabel2;
  13. @synthesize rightImage;
  14. @synthesize lineView;
  15. @synthesize checkButton;
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. // Initialization code
  19. }
  20. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  21. {
  22. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  23. if (self)
  24. {
  25. [self drawView];
  26. }
  27. return self;
  28. }
  29. - (void)drawView
  30. {
  31. cellBgView = [[UIView alloc] init];
  32. [self.contentView addSubview:cellBgView];
  33. //cellBgView.backgroundColor = [UIColor whiteColor];
  34. [cellBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.left.mas_equalTo(0.f);
  36. make.top.mas_equalTo(0);
  37. make.bottom.mas_equalTo(0);
  38. make.right.mas_equalTo(0.f);
  39. //make.width.mas_equalTo(SCREEN_W - 2*15.f);
  40. }];
  41. /*图片*/
  42. mImageView = [[UIImageView alloc] init];
  43. [mImageView setBackgroundColor:[UIColor clearColor]];
  44. mImageView.image = [UIImage imageNamed:@"uploadFile_disk_icon"];
  45. [cellBgView addSubview:mImageView];
  46. [mImageView setContentMode:(UIViewContentModeScaleAspectFill)];
  47. [mImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.mas_equalTo(15);
  49. make.width.mas_equalTo(36);
  50. make.height.mas_equalTo(36);
  51. make.centerY.equalTo(cellBgView.mas_centerY);
  52. }];
  53. /*右侧箭头*/
  54. rightImage = [[UIImageView alloc] init];
  55. [rightImage setBackgroundColor:[UIColor clearColor]];
  56. [rightImage setImage:[UIImage imageNamed:@"cell_right_access"]];
  57. [cellBgView addSubview:rightImage];
  58. [rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.width.mas_equalTo(28);
  60. make.right.mas_equalTo(-15.f);
  61. make.height.mas_equalTo(28);
  62. make.centerY.equalTo(cellBgView.mas_centerY);
  63. }];
  64. checkButton = [[UIButton alloc] init];
  65. [checkButton setImage:[UIImage imageNamed:@"upload_file_uncheck"] forState:UIControlStateNormal];
  66. [checkButton setImage:[UIImage imageNamed:@"upload_file_check"] forState:UIControlStateSelected];
  67. [cellBgView addSubview:checkButton];
  68. [checkButton mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.right.mas_equalTo(-18.f);
  70. make.centerY.equalTo(cellBgView.mas_centerY);
  71. make.width.mas_equalTo(36.f);
  72. make.height.mas_equalTo(36.f);
  73. }];
  74. [checkButton addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:(UIControlEventTouchUpInside)];
  75. /**标题*/
  76. titleLabel = [[UILabel alloc] init];
  77. [cellBgView addSubview:titleLabel];
  78. titleLabel.font = [UIFont boldSystemFontOfSize:14.f];
  79. titleLabel.numberOfLines = 0;
  80. [titleLabel setTextColor:HW0A132BColor];
  81. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.left.equalTo(mImageView.mas_right).offset(5.f);
  83. make.right.equalTo(checkButton.mas_left).offset(-5.f);
  84. //make.centerY.equalTo(cellBgView.mas_centerY);
  85. make.top.mas_equalTo(15.f);
  86. }];
  87. /**副标题*/
  88. titleLabel2 = [[UILabel alloc] init];
  89. [cellBgView addSubview:titleLabel2];
  90. titleLabel2.font = [UIFont systemFontOfSize:12.f];
  91. //[titleLabel2 setTextAlignment:(NSTextAlignmentRight)];
  92. [titleLabel2 setTextColor:HW666666Color];
  93. [titleLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.right.mas_equalTo(-53.f);
  95. make.left.mas_equalTo(titleLabel.mas_left);
  96. //make.centerY.equalTo(cellBgView.mas_centerY);
  97. make.bottom.mas_equalTo(-15);
  98. }];
  99. lineView = [[UIView alloc] init];
  100. [lineView setBackgroundColor:HW979797Color10];
  101. [cellBgView addSubview:lineView];
  102. [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.right.mas_equalTo(-15.f);
  104. make.left.mas_equalTo(15.f);
  105. make.bottom.mas_equalTo(0);
  106. make.height.mas_equalTo(1.f);
  107. }];
  108. //titleLabel2.text = @"30GB/128GB";
  109. }
  110. - (void)setCurModel:(cloudPhoneExtraFileModel *)curModel
  111. {
  112. titleLabel.text = curModel.name;
  113. CGFloat extraAvableSizeF = curModel.extraAvableSize / 1024.0 /1024.0/1024.0;
  114. CGFloat extraTotalSizeF = curModel.extraTotalSize / 1024.0 /1024.0/1024.0;
  115. titleLabel2.text = [[NSString alloc] initWithFormat:@"%.2fGB/%.2fGB",extraAvableSizeF,extraTotalSizeF];
  116. checkButton.selected = curModel.isCheckType;
  117. }
  118. - (void)maskSwitchPressed:(UIButton *)maskSwitch{
  119. maskSwitch.selected = !maskSwitch.selected;
  120. if(_didClickSwitch){
  121. _didClickSwitch(maskSwitch.selected);
  122. }
  123. }
  124. @end