allVersionView.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //
  2. // allVersionView.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/27.
  6. //
  7. #import "allVersionView.h"
  8. @interface allVersionView ()<UITableViewDelegate,UITableViewDataSource>
  9. {
  10. NSMutableArray*dataArr;
  11. }
  12. @property(nonatomic,strong)UIView *whiteBgView;
  13. @property(nonatomic,strong)UITableView *tableView;
  14. @end
  15. @implementation allVersionView
  16. - (id)initWithFrame:(CGRect)frame{
  17. self = [super initWithFrame:frame];
  18. [self drawAnyView];
  19. return self;
  20. }
  21. - (void)drawAnyView{
  22. dataArr = [NSMutableArray new];
  23. NSString *str1 = NSLocalizedString(@"my_set_about_version_tap_jingxiang",nil);
  24. NSString *str2 = NSLocalizedString(@"my_set_about_version_tap_daili",nil);
  25. NSString *str3 = NSLocalizedString(@"my_set_about_version_tap_app",nil);
  26. NSString *str4 = NSLocalizedString(@"my_set_about_version_tap_sn",nil);
  27. [dataArr addObject:str1];
  28. [dataArr addObject:str2];
  29. [dataArr addObject:str3];
  30. [dataArr addObject:str4];
  31. self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
  32. _whiteBgView = [[UIView alloc] init];
  33. _whiteBgView.backgroundColor = [UIColor whiteColor];
  34. _whiteBgView.layer.cornerRadius = 8;
  35. [self addSubview:_whiteBgView];
  36. [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.mas_equalTo(20);
  38. make.right.mas_equalTo(-20);
  39. make.height.mas_equalTo(2650);
  40. make.centerY.mas_equalTo(self.center).offset(-20);
  41. }];
  42. UIButton* delBut = [[UIButton alloc] init];
  43. [delBut setImage:[UIImage imageNamed:@"common_del"] forState:UIControlStateNormal];
  44. [delBut addTarget:self action:@selector(delViewFun) forControlEvents:UIControlEventTouchUpInside];
  45. [_whiteBgView addSubview:delBut];
  46. [delBut mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.top.mas_equalTo(0);
  48. make.right.mas_equalTo(0);
  49. make.width.mas_equalTo(40);
  50. make.height.mas_equalTo(40.0);
  51. }];
  52. UILabel * versionTipLabel = [[UILabel alloc] init];
  53. versionTipLabel.text = NSLocalizedString(@"my_set_about_version_tap_tip",nil) ;
  54. versionTipLabel.textAlignment = NSTextAlignmentCenter;
  55. versionTipLabel.font = [UIFont boldSystemFontOfSize:16.0];
  56. [_whiteBgView addSubview:versionTipLabel];
  57. [versionTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.mas_equalTo(15);
  59. make.right.mas_equalTo(-15);
  60. make.top.mas_equalTo(30);
  61. make.height.mas_equalTo(20.0);
  62. }];
  63. [_whiteBgView addSubview:self.tableView];
  64. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.mas_equalTo(15);
  66. make.right.mas_equalTo(-15);
  67. make.top.mas_equalTo(versionTipLabel.mas_bottom).offset(20);
  68. make.bottom.mas_equalTo(-16.0);
  69. }];
  70. }
  71. #pragma mark - 懒加载
  72. - (UITableView *)tableView{
  73. if (!_tableView) {
  74. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
  75. _tableView.delegate = self;
  76. _tableView.dataSource = self;
  77. _tableView.showsVerticalScrollIndicator = NO;
  78. _tableView.showsHorizontalScrollIndicator = NO;
  79. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  80. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  81. [_tableView setSeparatorColor:[UIColor clearColor]];
  82. [_tableView setBackgroundColor:[UIColor hwColor:@"#D8D8D8" alpha:1.0]];
  83. [_tableView setTableFooterView:[UIView new]];
  84. [_tableView setBounces:YES];
  85. _tableView.layer.cornerRadius = 8;
  86. if (@available(iOS 15.0, *)) {
  87. _tableView.sectionHeaderTopPadding = 0;
  88. }
  89. }
  90. return _tableView;
  91. }
  92. - (void)delViewFun
  93. {
  94. [self removeFromSuperview];
  95. }
  96. #pragma mark - 列表委托
  97. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  98. return dataArr.count;
  99. }
  100. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  101. NSInteger row = indexPath.row;
  102. static NSString *identifier = @"UITableViewCell";
  103. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  104. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  105. if (!cell){
  106. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  107. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  108. [cell setBackgroundColor:[UIColor clearColor]];
  109. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  110. cell.textLabel.font = [UIFont systemFontOfSize:12.0];
  111. cell.textLabel.textColor = [UIColor hwColor:@"#666666" alpha:1.0];
  112. }
  113. if(row < dataArr.count){
  114. cell.textLabel.text = dataArr[row];
  115. }
  116. return cell;
  117. }
  118. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  119. return 40;
  120. }
  121. @end