NASLastFileView.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //
  2. // NASLastFileView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/19.
  6. //
  7. #import "NASLastFileView.h"
  8. @interface NASLastFileView ()
  9. @property(nonatomic,strong) UILabel*titleLabel;
  10. @property(nonatomic,strong)UIButton *eyeButton;
  11. @end
  12. @implementation NASLastFileView
  13. - (id)initWithFrame:(CGRect)frame{
  14. self = [super initWithFrame:frame];
  15. //self.backgroundColor = [UIColor clearColor];
  16. [self drawAnyView];
  17. return self;
  18. }
  19. -(void)drawAnyView
  20. {
  21. UIView *whiteBgView = [[UIView alloc] init];
  22. whiteBgView.backgroundColor = [UIColor whiteColor];
  23. [self addSubview:whiteBgView];
  24. whiteBgView.layer.cornerRadius = 12;
  25. whiteBgView.layer.masksToBounds = YES;
  26. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.top.mas_equalTo(0);
  28. make.left.mas_equalTo(16);
  29. make.right.mas_equalTo(-16);
  30. make.bottom.mas_equalTo(0);
  31. }];
  32. _titleLabel = [[UILabel alloc] init];
  33. _titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  34. _titleLabel.textColor = [UIColor hwColor:@"#0A132B"];
  35. _titleLabel.text = NSLocalizedString(@"NAS_last_file",nil);
  36. [whiteBgView addSubview:_titleLabel];
  37. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.top.mas_equalTo(16);
  39. make.left.mas_equalTo(16);
  40. make.right.mas_equalTo(-24-12-10);
  41. make.height.mas_equalTo(20);
  42. }];
  43. //按钮
  44. UIButton *rightButton = [[UIButton alloc] init];
  45. [rightButton setBackgroundImage:[UIImage imageNamed:@"common_right_back_arrow"] forState:UIControlStateNormal];
  46. rightButton.tag = 1;
  47. [rightButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  48. [whiteBgView addSubview:rightButton];
  49. [rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.mas_equalTo(16);
  51. make.right.mas_equalTo(-12);
  52. make.width.mas_equalTo(24);
  53. make.height.mas_equalTo(24);
  54. }];
  55. UIView *lineView = [[UIView alloc] init];
  56. lineView.backgroundColor = [UIColor hwColor:@"#CFD1D4"];
  57. [whiteBgView addSubview:lineView];
  58. [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.equalTo(rightButton.mas_top).offset(5);
  60. make.width.mas_equalTo(1);
  61. make.right.equalTo(rightButton.mas_left).offset(-13);
  62. make.bottom.equalTo(rightButton.mas_bottom).offset(-5);
  63. }];
  64. //按钮
  65. _eyeButton = [[UIButton alloc] init];
  66. [_eyeButton setBackgroundImage:[UIImage imageNamed:@"common_eye_open_black"] forState:UIControlStateNormal];
  67. [_eyeButton setBackgroundImage:[UIImage imageNamed:@"common_eye_close_black"] forState:UIControlStateSelected];
  68. _eyeButton.tag = 2;
  69. [_eyeButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  70. [whiteBgView addSubview:_eyeButton];
  71. [_eyeButton mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.top.mas_equalTo(16);
  73. make.right.equalTo(lineView.mas_left).offset(-14);
  74. make.width.mas_equalTo(24);
  75. make.height.mas_equalTo(24);
  76. }];
  77. //空白页
  78. UIImageView* notDataImageV = [[UIImageView alloc] init];
  79. notDataImageV.image = [UIImage imageNamed:@"nas_not_data"];
  80. [whiteBgView addSubview:notDataImageV];
  81. [notDataImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.top.equalTo(_titleLabel.mas_bottom).offset(20);
  83. make.centerX.mas_equalTo(0);
  84. make.width.mas_equalTo(160);
  85. make.height.mas_equalTo(160);
  86. }];
  87. UILabel *notDataLabel = [[UILabel alloc] init];
  88. notDataLabel.font = [UIFont systemFontOfSize:14.0];
  89. notDataLabel.textColor = [UIColor hwColor:@"#999999"];
  90. notDataLabel.text = NSLocalizedString(@"NAS_last_file_not_data_tip",nil);
  91. notDataLabel.textAlignment = NSTextAlignmentCenter;
  92. [whiteBgView addSubview:notDataLabel];
  93. [notDataLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.top.equalTo(notDataImageV.mas_bottom).offset(-10);
  95. make.left.mas_equalTo(16);
  96. make.right.mas_equalTo(-16);
  97. make.height.mas_equalTo(20);
  98. }];
  99. }
  100. #pragma mark 按钮事件
  101. - (void)didClickButtonFun:(UIButton*)but
  102. {
  103. NSInteger tag = but.tag;
  104. HLog(@"%ld",tag);
  105. if(_didClickButtonFun){
  106. _didClickButtonFun(tag);
  107. }
  108. }
  109. @end