MineCommonUsedView.m 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. //
  2. // MineCommonUsedView.m
  3. // Private-X
  4. //
  5. // Created by xd h on 2024/6/21.
  6. //
  7. #import "MineCommonUsedView.h"
  8. @interface MineCommonUsedView ()
  9. @property(nonatomic,strong) UILabel*titleLabel;
  10. @end
  11. @implementation MineCommonUsedView
  12. - (id)initWithFrame:(CGRect)frame{
  13. self = [super initWithFrame:frame];
  14. //self.backgroundColor = [UIColor clearColor];
  15. [self drawAnyView];
  16. return self;
  17. }
  18. -(void)drawAnyView
  19. {
  20. UIView *whiteBgView = [[UIView alloc] init];
  21. whiteBgView.backgroundColor = [UIColor whiteColor];
  22. [self addSubview:whiteBgView];
  23. whiteBgView.layer.cornerRadius = 12;
  24. whiteBgView.layer.masksToBounds = YES;
  25. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.top.mas_equalTo(0);
  27. make.left.mas_equalTo(16);
  28. make.right.mas_equalTo(-16);
  29. make.bottom.mas_equalTo(0);
  30. }];
  31. _titleLabel = [[UILabel alloc] init];
  32. _titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  33. _titleLabel.textColor = [UIColor hwColor:@"#0A132B"];
  34. _titleLabel.text = NSLocalizedString(@"NAS_common_used",nil);
  35. [whiteBgView addSubview:_titleLabel];
  36. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.top.mas_equalTo(16);
  38. make.left.mas_equalTo(16);
  39. make.right.mas_equalTo(-24-12-10);
  40. make.height.mas_equalTo(20);
  41. }];
  42. NSArray *titleArr = @[NSLocalizedString(@"my_set_Privacy_Model",nil),
  43. //NSLocalizedString(@"mine_cloudPhone_Model_title",nil),
  44. //NSLocalizedString(@"mine_help_title",nil),
  45. NSLocalizedString(@"my_set_no_change_phone",nil),
  46. NSLocalizedString(@"my_set_no_connect_kefu",nil),
  47. NSLocalizedString(@"my_set_no_clear_cache",nil),
  48. NSLocalizedString(@"my_set_no_check_update",nil),
  49. NSLocalizedString(@"mine_record_title",nil),
  50. //NSLocalizedString(@"mine_newuser_title",nil),
  51. //NSLocalizedString(@"mine_sn_cancel_title",nil)
  52. ];
  53. NSArray *imageArr = @[@"mine_Privacy_icon",
  54. //@"mine_cloudPhone_model_icon",
  55. @"mine_changePhone_icon",
  56. @"mine_help_icon",
  57. @"mine_clear_icon",
  58. @"mine_customer_icon",
  59. @"mine_record_icon",
  60. //@"mine_version_icon",
  61. //@"mine_newUser_icon",
  62. //@"mine_cancell_icon",
  63. ];
  64. if(ksharedAppDelegate.DeviceThirdIdMod
  65. && ![ksharedAppDelegate.DeviceThirdIdMod.data.changeSn isEqualToString:@"0333933700223110016962"]){
  66. titleArr = @[NSLocalizedString(@"my_set_Privacy_Model",nil),
  67. //NSLocalizedString(@"mine_cloudPhone_Model_title",nil),
  68. //NSLocalizedString(@"mine_help_title",nil),
  69. NSLocalizedString(@"my_set_no_change_phone",nil),
  70. NSLocalizedString(@"my_set_no_connect_kefu",nil),
  71. NSLocalizedString(@"my_set_no_clear_cache",nil),
  72. NSLocalizedString(@"my_set_no_check_update",nil),
  73. //NSLocalizedString(@"mine_record_title",nil),
  74. //NSLocalizedString(@"mine_newuser_title",nil),
  75. //NSLocalizedString(@"mine_sn_cancel_title",nil)
  76. ];
  77. imageArr = @[@"mine_Privacy_icon",
  78. //@"mine_cloudPhone_model_icon",
  79. @"mine_changePhone_icon",
  80. @"mine_help_icon",
  81. @"mine_clear_icon",
  82. @"mine_customer_icon",
  83. //@"mine_record_icon",
  84. //@"mine_version_icon",
  85. //@"mine_newUser_icon",
  86. //@"mine_cancell_icon",
  87. ];
  88. }
  89. CGFloat butTopY = 50.0;
  90. CGFloat imageWH = 28.0;
  91. CGFloat butHeight = imageWH +20 +5;
  92. CGFloat butWidth = 70.0;
  93. CGFloat butSpace = (SCREEN_W -16*2 - butWidth*4)/5.0;
  94. for (int i=0; i<titleArr.count; i++) {
  95. UIButton *but = [[UIButton alloc] init];
  96. but.tag = 10+i;
  97. [but addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  98. [whiteBgView addSubview:but];
  99. //but.backgroundColor = [UIColor greenColor];
  100. [but mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.left.mas_equalTo(butSpace + (butWidth+butSpace)*(i%4));
  102. make.width.mas_equalTo(butWidth);
  103. make.height.mas_equalTo(butHeight);
  104. make.top.mas_equalTo(butTopY + (i/4)* (butHeight + 25) );
  105. }];
  106. UIImageView *imageV = [[UIImageView alloc] init];
  107. imageV.image = [UIImage imageNamed:imageArr[i]];
  108. // imageV.layer.cornerRadius = 10;
  109. // imageV.layer.masksToBounds = YES;
  110. [but addSubview:imageV];
  111. [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.centerX.mas_equalTo(0);
  113. make.width.mas_equalTo(imageWH);
  114. make.height.mas_equalTo(imageWH);
  115. make.top.mas_equalTo(0);
  116. }];
  117. UILabel *textLabel = [[UILabel alloc] init];
  118. textLabel.textAlignment = NSTextAlignmentCenter;
  119. textLabel.font = [UIFont systemFontOfSize:13.0];
  120. textLabel.textColor = [UIColor hwColor:@"#828D9A"];
  121. textLabel.text = titleArr[i];
  122. textLabel.numberOfLines = 0;
  123. [but addSubview:textLabel];
  124. //textLabel.backgroundColor = [UIColor redColor];
  125. [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.centerX.mas_equalTo(0);
  127. make.width.mas_equalTo(butWidth);
  128. make.height.mas_equalTo(35);
  129. make.top.equalTo(imageV.mas_bottom).offset(5);
  130. }];
  131. }
  132. }
  133. #pragma mark 按钮事件
  134. - (void)didClickButtonFun:(UIButton*)but
  135. {
  136. NSInteger tag = but.tag;
  137. HLog(@"%ld",tag);
  138. if(_didClickButtonFun){
  139. _didClickButtonFun(tag);
  140. }
  141. }
  142. @end