MineViewCell.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. //
  2. // MineViewCell.m
  3. // VclustersGemini
  4. //
  5. // Created by 黄盛威 on 2020/10/19.
  6. // Copyright © 2020 APPLE. All rights reserved.
  7. //
  8. #import "MineViewCell.h"
  9. @implementation MineViewCell
  10. @synthesize cellBgView;
  11. @synthesize mImageView;
  12. @synthesize titleLabel;
  13. @synthesize titleLabel2;
  14. @synthesize rightImage;
  15. @synthesize lineView;
  16. @synthesize maskSwitch;
  17. - (void)awakeFromNib {
  18. [super awakeFromNib];
  19. // Initialization code
  20. }
  21. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  22. {
  23. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  24. if (self)
  25. {
  26. [self drawView];
  27. }
  28. return self;
  29. }
  30. - (void)drawView
  31. {
  32. cellBgView = [[UIView alloc] init];
  33. [self.contentView addSubview:cellBgView];
  34. cellBgView.backgroundColor = [UIColor whiteColor];
  35. [cellBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(15.f);
  37. make.top.mas_equalTo(0);
  38. make.bottom.mas_equalTo(0);
  39. make.width.mas_equalTo(SCREEN_W - 2*15.f);
  40. }];
  41. /*图片*/
  42. mImageView = [[UIImageView alloc] init];
  43. [mImageView setBackgroundColor:[UIColor clearColor]];
  44. [cellBgView addSubview:mImageView];
  45. [mImageView setContentMode:(UIViewContentModeScaleAspectFill)];
  46. [mImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.left.mas_equalTo(15);
  48. make.width.mas_equalTo(28);
  49. make.height.mas_equalTo(28);
  50. make.centerY.equalTo(cellBgView.mas_centerY);
  51. }];
  52. /*右侧箭头*/
  53. rightImage = [[UIImageView alloc] init];
  54. [rightImage setBackgroundColor:[UIColor clearColor]];
  55. [rightImage setImage:[UIImage imageNamed:@"cell_right_access"]];
  56. [cellBgView addSubview:rightImage];
  57. [rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.width.mas_equalTo(28);
  59. make.right.mas_equalTo(-15.f);
  60. make.height.mas_equalTo(28);
  61. make.centerY.equalTo(cellBgView.mas_centerY);
  62. }];
  63. maskSwitch = [[UISwitch alloc] init];
  64. [cellBgView addSubview:maskSwitch];
  65. [maskSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.right.mas_equalTo(-18.f);
  67. make.centerY.equalTo(cellBgView.mas_centerY);
  68. }];
  69. [maskSwitch setOnTintColor:HW13B2EBColor];
  70. [maskSwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:(UIControlEventValueChanged)];
  71. // BOOL haveOpenMask = [HWDataManager getBoolWithKey:Consn_Fanzhuan_Exit_app_Open];
  72. // [maskSwitch setOn:haveOpenMask];
  73. /**标题*/
  74. titleLabel = [[UILabel alloc] init];
  75. [cellBgView addSubview:titleLabel];
  76. titleLabel.font = [UIFont systemFontOfSize:13.f];
  77. [titleLabel setTextColor:HW0A132BColor];
  78. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.left.equalTo(mImageView.mas_right).offset(5.f);
  80. make.right.mas_equalTo(-100.f);
  81. make.centerY.equalTo(cellBgView.mas_centerY);
  82. }];
  83. /**副标题*/
  84. titleLabel2 = [[UILabel alloc] init];
  85. [cellBgView addSubview:titleLabel2];
  86. titleLabel2.font = [UIFont systemFontOfSize:12.f];
  87. [titleLabel2 setTextAlignment:(NSTextAlignmentRight)];
  88. [titleLabel2 setTextColor:HW666666Color];
  89. [titleLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.right.mas_equalTo(-53.f);
  91. make.left.mas_equalTo(100.f);
  92. make.centerY.equalTo(cellBgView.mas_centerY);
  93. }];
  94. lineView = [[UIView alloc] init];
  95. [lineView setBackgroundColor:HW979797Color10];
  96. [cellBgView addSubview:lineView];
  97. [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.right.mas_equalTo(-15.f);
  99. make.left.mas_equalTo(15.f);
  100. make.bottom.mas_equalTo(0);
  101. make.height.mas_equalTo(1.f);
  102. }];
  103. }
  104. - (void)maskSwitchPressed:(UISwitch *)maskSwitch{
  105. if (_didClickMaskSwitch) {
  106. _didClickMaskSwitch(maskSwitch);
  107. }
  108. else{//之前的逻辑 有时间再完善
  109. [HWDataManager setBoolWithKey:Consn_Fanzhuan_Exit_app_Open value:maskSwitch.on];
  110. if (maskSwitch.on) {
  111. [[iToast makeText:NSLocalizedString(@"my_set_no_fanzhuan_exit_open",nil)] show];
  112. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Overturn_on"];
  113. }
  114. else{
  115. [[iToast makeText:NSLocalizedString(@"my_set_no_fanzhuan_exit_close",nil)] show];
  116. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Overturn_off"];
  117. }
  118. }
  119. }
  120. @end