fileSetTableViewCell.m 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //
  2. // fileSetTableViewCell.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/12/28.
  6. //
  7. #import "fileSetTableViewCell.h"
  8. @implementation fileSetTableViewCell
  9. @synthesize cellBgView;
  10. @synthesize mImageView;
  11. @synthesize titleLabel;
  12. @synthesize titleLabel2;
  13. @synthesize rightImage;
  14. @synthesize lineView;
  15. @synthesize maskSwitch;
  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(15.f);
  36. make.top.mas_equalTo(0);
  37. make.bottom.mas_equalTo(0);
  38. make.width.mas_equalTo(SCREEN_W - 2*15.f);
  39. }];
  40. /*图片*/
  41. mImageView = [[UIImageView alloc] init];
  42. [mImageView setBackgroundColor:[UIColor clearColor]];
  43. [cellBgView addSubview:mImageView];
  44. [mImageView setContentMode:(UIViewContentModeScaleAspectFill)];
  45. [mImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.left.mas_equalTo(15);
  47. make.width.mas_equalTo(28);
  48. make.height.mas_equalTo(28);
  49. make.centerY.equalTo(cellBgView.mas_centerY);
  50. }];
  51. /*右侧箭头*/
  52. rightImage = [[UIImageView alloc] init];
  53. [rightImage setBackgroundColor:[UIColor clearColor]];
  54. [rightImage setImage:[UIImage imageNamed:@"cell_right_access"]];
  55. [cellBgView addSubview:rightImage];
  56. [rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.width.mas_equalTo(28);
  58. make.right.mas_equalTo(-15.f);
  59. make.height.mas_equalTo(28);
  60. make.centerY.equalTo(cellBgView.mas_centerY);
  61. }];
  62. maskSwitch = [[UISwitch alloc] init];
  63. [cellBgView addSubview:maskSwitch];
  64. [maskSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.right.mas_equalTo(-18.f);
  66. make.centerY.equalTo(cellBgView.mas_centerY);
  67. }];
  68. [maskSwitch setOnTintColor:HW13B2EBColor];
  69. [maskSwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:(UIControlEventValueChanged)];
  70. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Consn_Fanzhuan_Exit_app_Open];
  71. [maskSwitch setOn:haveOpenMask];
  72. /**标题*/
  73. titleLabel = [[UILabel alloc] init];
  74. [cellBgView addSubview:titleLabel];
  75. titleLabel.font = [UIFont boldSystemFontOfSize:14.f];
  76. //titleLabel.adjustsFontSizeToFitWidth = YES;
  77. titleLabel.numberOfLines = 2;
  78. [titleLabel setTextColor:HW0A132BColor];
  79. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  80. //make.left.equalTo(mImageView.mas_right).offset(5.f);
  81. make.left.mas_equalTo(10.f);
  82. make.right.mas_equalTo(-60.f);
  83. make.centerY.equalTo(cellBgView.mas_centerY);
  84. make.height.mas_equalTo(35.f);
  85. }];
  86. /**副标题*/
  87. titleLabel2 = [[UILabel alloc] init];
  88. [cellBgView addSubview:titleLabel2];
  89. titleLabel2.font = [UIFont systemFontOfSize:12.f];
  90. [titleLabel2 setTextAlignment:(NSTextAlignmentRight)];
  91. [titleLabel2 setTextColor:HW666666Color];
  92. [titleLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.right.mas_equalTo(-53.f);
  94. make.left.mas_equalTo(100.f);
  95. make.centerY.equalTo(cellBgView.mas_centerY);
  96. }];
  97. lineView = [[UIView alloc] init];
  98. [lineView setBackgroundColor:HW979797Color10];
  99. [cellBgView addSubview:lineView];
  100. [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.right.mas_equalTo(-15.f);
  102. make.left.mas_equalTo(15.f);
  103. make.bottom.mas_equalTo(0);
  104. make.height.mas_equalTo(1.f);
  105. }];
  106. }
  107. - (void)maskSwitchPressed:(UISwitch *)maskSwitch{
  108. if(_didClickSwitch){
  109. _didClickSwitch(maskSwitch.on);
  110. }
  111. }
  112. @end