MineCommonUsedView~.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //
  2. // MineCommonUsedView.m
  3. // 双子星云手机
  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_newuser_title",nil),
  50. //NSLocalizedString(@"mine_sn_cancel_title",nil)
  51. ];
  52. NSArray *imageArr = @[@"mine_Privacy_icon",
  53. @"mine_cloudPhone_model_icon",
  54. @"mine_help_icon",
  55. @"mine_changePhone_icon",
  56. @"mine_customer_icon",
  57. @"mine_clear_icon",
  58. @"mine_version_icon",
  59. @"mine_newUser_icon",
  60. //@"mine_cancell_icon",
  61. ];
  62. CGFloat butTopY = 50.0;
  63. CGFloat imageWH = 28.0;
  64. CGFloat butHeight = imageWH +20 +5;
  65. CGFloat butWidth = 70.0;
  66. CGFloat butSpace = (SCREEN_W -16*2 - butWidth*4)/5.0;
  67. for (int i=0; i<titleArr.count; i++) {
  68. UIButton *but = [[UIButton alloc] init];
  69. but.tag = 10+i;
  70. [but addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  71. [whiteBgView addSubview:but];
  72. //but.backgroundColor = [UIColor greenColor];
  73. [but mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.left.mas_equalTo(butSpace + (butWidth+butSpace)*(i%4));
  75. make.width.mas_equalTo(butWidth);
  76. make.height.mas_equalTo(butHeight);
  77. make.top.mas_equalTo(butTopY + (i/4)* (butHeight + 25) );
  78. }];
  79. UIImageView *imageV = [[UIImageView alloc] init];
  80. imageV.image = [UIImage imageNamed:imageArr[i]];
  81. // imageV.layer.cornerRadius = 10;
  82. // imageV.layer.masksToBounds = YES;
  83. [but addSubview:imageV];
  84. [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.centerX.mas_equalTo(0);
  86. make.width.mas_equalTo(imageWH);
  87. make.height.mas_equalTo(imageWH);
  88. make.top.mas_equalTo(0);
  89. }];
  90. UILabel *textLabel = [[UILabel alloc] init];
  91. textLabel.textAlignment = NSTextAlignmentCenter;
  92. textLabel.font = [UIFont systemFontOfSize:13.0];
  93. textLabel.textColor = [UIColor hwColor:@"#828D9A"];
  94. textLabel.text = titleArr[i];
  95. textLabel.numberOfLines = 0;
  96. [but addSubview:textLabel];
  97. //textLabel.backgroundColor = [UIColor redColor];
  98. [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.centerX.mas_equalTo(0);
  100. make.width.mas_equalTo(butWidth);
  101. make.height.mas_equalTo(35);
  102. make.top.equalTo(imageV.mas_bottom).offset(5);
  103. }];
  104. }
  105. }
  106. #pragma mark 按钮事件
  107. - (void)didClickButtonFun:(UIButton*)but
  108. {
  109. NSInteger tag = but.tag;
  110. HLog(@"%ld",tag);
  111. if(_didClickButtonFun){
  112. _didClickButtonFun(tag);
  113. }
  114. }
  115. @end