NASCommonUsedView~.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // NASCommonUsedView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/19.
  6. //
  7. #import "NASCommonUsedView.h"
  8. @interface NASCommonUsedView ()
  9. {
  10. UIView* rightRedView;
  11. }
  12. @property(nonatomic,strong) UILabel*titleLabel;
  13. @end
  14. @implementation NASCommonUsedView
  15. - (id)initWithFrame:(CGRect)frame{
  16. self = [super initWithFrame:frame];
  17. //self.backgroundColor = [UIColor clearColor];
  18. [self drawAnyView];
  19. return self;
  20. }
  21. -(void)drawAnyView
  22. {
  23. UIView *whiteBgView = [[UIView alloc] init];
  24. whiteBgView.backgroundColor = [UIColor whiteColor];
  25. [self addSubview:whiteBgView];
  26. whiteBgView.layer.cornerRadius = 12;
  27. whiteBgView.layer.masksToBounds = YES;
  28. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.top.mas_equalTo(0);
  30. make.left.mas_equalTo(16);
  31. make.right.mas_equalTo(-16);
  32. make.bottom.mas_equalTo(0);
  33. }];
  34. _titleLabel = [[UILabel alloc] init];
  35. _titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  36. _titleLabel.textColor = [UIColor hwColor:@"#0A132B"];
  37. _titleLabel.text = NSLocalizedString(@"NAS_common_used",nil);
  38. [whiteBgView addSubview:_titleLabel];
  39. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.top.mas_equalTo(16);
  41. make.left.mas_equalTo(16);
  42. make.right.mas_equalTo(-24-12-10);
  43. make.height.mas_equalTo(20);
  44. }];
  45. NSArray *titleArr = @[NSLocalizedString(@"my_set_no_File_backups",nil),
  46. NSLocalizedString(@"set_file_Transfer_WWAN_title2",nil),
  47. NSLocalizedString(@"my_set_no_share2",nil)
  48. //,NSLocalizedString(@"my_set_no_share",nil)
  49. ];
  50. NSArray *imageArr = @[@"nas_backups_icon",
  51. @"nas_set_icon",
  52. @"nas_share_icon"
  53. //,@"nas_share_icon"
  54. ];
  55. CGFloat butTopY = 50.0;
  56. CGFloat imageWH = 32.0;
  57. CGFloat butHeight = imageWH +20 +5;
  58. CGFloat butWidth = 70.0;
  59. CGFloat butSpace = (SCREEN_W -16*2 - butWidth*4)/5.0;
  60. for (int i=0; i<titleArr.count; i++) {
  61. UIButton *but = [[UIButton alloc] init];
  62. but.tag = 10+i;
  63. [but addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  64. [whiteBgView addSubview:but];
  65. // but.backgroundColor = [UIColor greenColor];
  66. [but mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.mas_equalTo(butSpace + (butWidth+butSpace)*(i%4));
  68. make.width.mas_equalTo(butWidth);
  69. make.height.mas_equalTo(butHeight);
  70. make.top.mas_equalTo(butTopY + (i/4)* (butHeight + 25) );
  71. }];
  72. UIImageView *imageV = [[UIImageView alloc] init];
  73. imageV.image = [UIImage imageNamed:imageArr[i]];
  74. // imageV.layer.cornerRadius = 10;
  75. // imageV.layer.masksToBounds = YES;
  76. [but addSubview:imageV];
  77. [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.centerX.mas_equalTo(0);
  79. make.width.mas_equalTo(imageWH);
  80. make.height.mas_equalTo(imageWH);
  81. make.top.mas_equalTo(0);
  82. }];
  83. UILabel *textLabel = [[UILabel alloc] init];
  84. textLabel.textAlignment = NSTextAlignmentCenter;
  85. textLabel.font = [UIFont systemFontOfSize:14.0];
  86. textLabel.textColor = [UIColor hwColor:@"#0A132B"];
  87. textLabel.text = titleArr[i];
  88. [but addSubview:textLabel];
  89. //textLabel.backgroundColor = [UIColor redColor];
  90. [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.centerX.mas_equalTo(0);
  92. make.width.mas_equalTo(butWidth);
  93. make.height.mas_equalTo(20);
  94. make.top.equalTo(imageV.mas_bottom).offset(5);
  95. }];
  96. if(i==2){
  97. rightRedView = [[UIView alloc] init];
  98. rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
  99. [imageV addSubview:rightRedView];
  100. rightRedView.layer.cornerRadius = 6;
  101. rightRedView.hidden = YES;
  102. [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.width.mas_equalTo(12);
  104. make.height.mas_equalTo(12);
  105. make.right.mas_equalTo(0);
  106. make.top.mas_equalTo(0);
  107. }];
  108. }
  109. }
  110. }
  111. #pragma mark 按钮事件
  112. - (void)didClickButtonFun:(UIButton*)but
  113. {
  114. NSInteger tag = but.tag;
  115. HLog(@"%ld",tag);
  116. if(_didClickButtonFun){
  117. _didClickButtonFun(tag);
  118. }
  119. }
  120. - (void)setRedPointShow:(BOOL)isShow
  121. {
  122. rightRedView.hidden = !isShow;
  123. }
  124. @end