123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- //
- // NASCommonUsedView.m
- // 双子星云手机
- //
- // Created by xd h on 2024/6/19.
- //
- #import "NASCommonUsedView.h"
- @interface NASCommonUsedView ()
- {
- UIView* rightRedView;
- }
- @property(nonatomic,strong) UILabel*titleLabel;
- @end
- @implementation NASCommonUsedView
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
-
- //self.backgroundColor = [UIColor clearColor];
- [self drawAnyView];
-
- return self;
- }
- -(void)drawAnyView
- {
- UIView *whiteBgView = [[UIView alloc] init];
- whiteBgView.backgroundColor = [UIColor whiteColor];
- [self addSubview:whiteBgView];
- whiteBgView.layer.cornerRadius = 12;
- whiteBgView.layer.masksToBounds = YES;
-
- [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(16);
- make.right.mas_equalTo(-16);
- make.bottom.mas_equalTo(0);
- }];
-
- _titleLabel = [[UILabel alloc] init];
- _titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
- _titleLabel.textColor = [UIColor hwColor:@"#0A132B"];
- _titleLabel.text = NSLocalizedString(@"NAS_common_used",nil);
- [whiteBgView addSubview:_titleLabel];
-
- [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(16);
- make.left.mas_equalTo(16);
- make.right.mas_equalTo(-24-12-10);
- make.height.mas_equalTo(20);
- }];
-
- NSArray *titleArr = @[NSLocalizedString(@"my_set_no_File_backups",nil),
- NSLocalizedString(@"set_file_Transfer_WWAN_title2",nil),
- NSLocalizedString(@"my_set_no_share2",nil)
- //,NSLocalizedString(@"my_set_no_share",nil)
- ];
-
- NSArray *imageArr = @[@"nas_backups_icon",
- @"nas_set_icon",
- @"nas_share_icon"
- //,@"nas_share_icon"
- ];
-
- CGFloat butTopY = 50.0;
- CGFloat imageWH = 32.0;
- CGFloat butHeight = imageWH +20 +5;
- CGFloat butWidth = 70.0;
- CGFloat butSpace = (SCREEN_W -16*2 - butWidth*4)/5.0;
-
- for (int i=0; i<titleArr.count; i++) {
-
- UIButton *but = [[UIButton alloc] init];
- but.tag = 10+i;
- [but addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- [whiteBgView addSubview:but];
- // but.backgroundColor = [UIColor greenColor];
-
- [but mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(butSpace + (butWidth+butSpace)*(i%4));
- make.width.mas_equalTo(butWidth);
- make.height.mas_equalTo(butHeight);
- make.top.mas_equalTo(butTopY + (i/4)* (butHeight + 25) );
- }];
-
- UIImageView *imageV = [[UIImageView alloc] init];
- imageV.image = [UIImage imageNamed:imageArr[i]];
- // imageV.layer.cornerRadius = 10;
- // imageV.layer.masksToBounds = YES;
- [but addSubview:imageV];
-
- [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(0);
- make.width.mas_equalTo(imageWH);
- make.height.mas_equalTo(imageWH);
- make.top.mas_equalTo(0);
- }];
-
- UILabel *textLabel = [[UILabel alloc] init];
- textLabel.textAlignment = NSTextAlignmentCenter;
- textLabel.font = [UIFont systemFontOfSize:14.0];
- textLabel.textColor = [UIColor hwColor:@"#0A132B"];
- textLabel.text = titleArr[i];
- [but addSubview:textLabel];
- //textLabel.backgroundColor = [UIColor redColor];
-
- [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(0);
- make.width.mas_equalTo(butWidth);
- make.height.mas_equalTo(20);
- make.top.equalTo(imageV.mas_bottom).offset(5);
- }];
-
- if(i==2){
- rightRedView = [[UIView alloc] init];
- rightRedView.backgroundColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
- [imageV addSubview:rightRedView];
- rightRedView.layer.cornerRadius = 6;
- rightRedView.hidden = YES;
-
- [rightRedView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(12);
- make.height.mas_equalTo(12);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
- }
-
- }
-
- }
- #pragma mark 按钮事件
- - (void)didClickButtonFun:(UIButton*)but
- {
- NSInteger tag = but.tag;
- HLog(@"%ld",tag);
-
- if(_didClickButtonFun){
- _didClickButtonFun(tag);
- }
- }
- - (void)setRedPointShow:(BOOL)isShow
- {
- rightRedView.hidden = !isShow;
- }
- @end
|