MineCommonUsedView.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //
  2. // MineCommonUsedView.m
  3. //
  4. //
  5. // Created by David 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. if(butSpace < 0){
  68. butSpace = 0.0;
  69. }
  70. for (int i=0; i<titleArr.count; i++) {
  71. UIButton *but = [[UIButton alloc] init];
  72. but.tag = 10+i;
  73. [but addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  74. [whiteBgView addSubview:but];
  75. //but.backgroundColor = [UIColor greenColor];
  76. [but mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.left.mas_equalTo(butSpace + (butWidth+butSpace)*(i%4));
  78. make.width.mas_equalTo(butWidth);
  79. make.height.mas_equalTo(butHeight);
  80. make.top.mas_equalTo(butTopY + (i/4)* (butHeight + 25) );
  81. }];
  82. UIImageView *imageV = [[UIImageView alloc] init];
  83. imageV.image = [UIImage imageNamed:imageArr[i]];
  84. // imageV.layer.cornerRadius = 10;
  85. // imageV.layer.masksToBounds = YES;
  86. [but addSubview:imageV];
  87. [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.centerX.mas_equalTo(0);
  89. make.width.mas_equalTo(imageWH);
  90. make.height.mas_equalTo(imageWH);
  91. make.top.mas_equalTo(0);
  92. }];
  93. UILabel *textLabel = [[UILabel alloc] init];
  94. textLabel.textAlignment = NSTextAlignmentCenter;
  95. textLabel.font = [UIFont systemFontOfSize:13.0];
  96. textLabel.textColor = [UIColor hwColor:@"#828D9A"];
  97. textLabel.text = titleArr[i];
  98. textLabel.numberOfLines = 0;
  99. [but addSubview:textLabel];
  100. //textLabel.backgroundColor = [UIColor redColor];
  101. [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  102. make.centerX.mas_equalTo(0);
  103. make.width.mas_equalTo(butWidth);
  104. make.height.mas_equalTo(35);
  105. make.top.equalTo(imageV.mas_bottom).offset(5);
  106. }];
  107. }
  108. }
  109. #pragma mark 按钮事件
  110. - (void)didClickButtonFun:(UIButton*)but
  111. {
  112. NSInteger tag = but.tag;
  113. HLog(@"%ld",tag);
  114. if(_didClickButtonFun){
  115. _didClickButtonFun(tag);
  116. }
  117. }
  118. @end