|
@@ -0,0 +1,200 @@
|
|
|
+//
|
|
|
+// NASMySpaceView.m
|
|
|
+// 双子星云手机
|
|
|
+//
|
|
|
+// Created by xd h on 2024/6/19.
|
|
|
+//
|
|
|
+
|
|
|
+#import "NASMySpaceView.h"
|
|
|
+
|
|
|
+@interface NASMySpaceView ()
|
|
|
+@property(nonatomic,strong) UILabel*titleLabel;
|
|
|
+
|
|
|
+//渐变色进度条
|
|
|
+@property(nonatomic,strong) UIView *progressBgView;
|
|
|
+@property(nonatomic,strong) UIView *progressSelectView;
|
|
|
+@property(nonatomic,strong) CAGradientLayer *glayer;
|
|
|
+
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation NASMySpaceView
|
|
|
+
|
|
|
+- (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 systemFontOfSize:12.0];
|
|
|
+ _titleLabel.textColor = [UIColor hwColor:@"#818CA2"];
|
|
|
+ [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);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self setTitleLabelTextFun];
|
|
|
+
|
|
|
+ //添加按钮
|
|
|
+ UIButton *rightButton = [[UIButton alloc] init];
|
|
|
+ [rightButton setBackgroundImage:[UIImage imageNamed:@"common_right_arrow"] forState:UIControlStateNormal];
|
|
|
+ rightButton.tag = 1;
|
|
|
+ [rightButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [whiteBgView addSubview:rightButton];
|
|
|
+
|
|
|
+ [rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.mas_equalTo(16);
|
|
|
+ make.right.mas_equalTo(-12);
|
|
|
+ make.width.mas_equalTo(24);
|
|
|
+ make.height.mas_equalTo(24);
|
|
|
+ }];
|
|
|
+
|
|
|
+ _progressBgView = [[UIView alloc] init];
|
|
|
+ _progressBgView.backgroundColor = [UIColor hwColor:@"#E7EFFA" alpha:1.0];
|
|
|
+ _progressBgView.layer.cornerRadius = 5;
|
|
|
+ _progressBgView.layer.masksToBounds = YES;
|
|
|
+ [whiteBgView addSubview:_progressBgView];
|
|
|
+
|
|
|
+ [_progressBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(16);
|
|
|
+ make.right.mas_equalTo(-16);
|
|
|
+ make.height.mas_equalTo(10);
|
|
|
+ make.top.equalTo(_titleLabel.mas_bottom).offset(12);
|
|
|
+ }];
|
|
|
+
|
|
|
+ _progressSelectView = [[UIView alloc] init];
|
|
|
+ _progressSelectView.layer.cornerRadius = 5;
|
|
|
+ _progressSelectView.layer.masksToBounds = YES;
|
|
|
+ [_progressBgView addSubview:_progressSelectView];
|
|
|
+
|
|
|
+ // gradient
|
|
|
+ _glayer = [CAGradientLayer layer];
|
|
|
+ _glayer.startPoint = CGPointMake(0, 0.5);
|
|
|
+ _glayer.endPoint = CGPointMake(0.97, 0.5);
|
|
|
+ _glayer.colors = @[(__bridge id)[UIColor hwColor:@"#0CDEFD" alpha:1.0].CGColor, (__bridge id)[UIColor hwColor:@"#058DFB" alpha:1.0].CGColor];
|
|
|
+ _glayer.locations = @[@(0), @(1.0f)];
|
|
|
+ [_progressSelectView.layer addSublayer:_glayer];
|
|
|
+
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [self setProgressFun];
|
|
|
+ });
|
|
|
+
|
|
|
+ NSArray *titleArr = @[NSLocalizedString(@"my_set_no_image_upload",nil),
|
|
|
+ NSLocalizedString(@"my_set_no_video_upload",nil),
|
|
|
+ NSLocalizedString(@"my_set_no_music",nil),
|
|
|
+ NSLocalizedString(@"my_set_no_file",nil)];
|
|
|
+
|
|
|
+ NSArray *imageArr = @[NSLocalizedString(@"nas_picture_icon",nil),
|
|
|
+ NSLocalizedString(@"nas_video_icon",nil),
|
|
|
+ NSLocalizedString(@"nas_audio_icon",nil),
|
|
|
+ NSLocalizedString(@"nas_file_icon",nil)];
|
|
|
+
|
|
|
+ CGFloat butTopY = 74.0;
|
|
|
+ CGFloat butWidth = 52.0;
|
|
|
+ CGFloat butHeight = 52.0 +20 +5;
|
|
|
+ CGFloat butSpace = (SCREEN_W -16*2 - butWidth*titleArr.count)/5.0;
|
|
|
+
|
|
|
+
|
|
|
+ for (int i=0; i<titleArr.count; i++) {
|
|
|
+ UIImageView *imageV = [[UIImageView alloc] init];
|
|
|
+ imageV.image = [UIImage imageNamed:imageArr[i]];
|
|
|
+ imageV.backgroundColor = [UIColor hwColor:@"#F5F6F7"];
|
|
|
+ imageV.layer.cornerRadius = 10;
|
|
|
+ imageV.layer.masksToBounds = YES;
|
|
|
+ [whiteBgView addSubview:imageV];
|
|
|
+
|
|
|
+ [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(butSpace + (butWidth+butSpace)*i);
|
|
|
+ make.width.mas_equalTo(butWidth);
|
|
|
+ make.height.mas_equalTo(butWidth);
|
|
|
+ make.top.mas_equalTo(butTopY);
|
|
|
+ }];
|
|
|
+
|
|
|
+ UILabel *textLabel = [[UILabel alloc] init];
|
|
|
+ textLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
+ textLabel.font = [UIFont systemFontOfSize:14.0];
|
|
|
+ textLabel.textColor = [UIColor hwColor:@"#0A132B"];
|
|
|
+ textLabel.text = titleArr[i];
|
|
|
+ [whiteBgView addSubview:textLabel];
|
|
|
+
|
|
|
+ [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(butSpace + (butWidth+butSpace)*i);
|
|
|
+ make.width.mas_equalTo(butWidth);
|
|
|
+ make.height.mas_equalTo(20);
|
|
|
+ make.top.equalTo(imageV.mas_bottom).offset(5);
|
|
|
+ }];
|
|
|
+
|
|
|
+ UIButton *but = [[UIButton alloc] init];
|
|
|
+ but.tag = 10+i;
|
|
|
+ [but addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [whiteBgView addSubview:but];
|
|
|
+
|
|
|
+ [but mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(butSpace + (butWidth+butSpace)*i);
|
|
|
+ make.width.mas_equalTo(butWidth);
|
|
|
+ make.height.mas_equalTo(butHeight);
|
|
|
+ make.top.mas_equalTo(butTopY);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)setTitleLabelTextFun
|
|
|
+{
|
|
|
+ NSString*title1 = NSLocalizedString(@"NAS_mySpace_title",nil);
|
|
|
+ NSString*title2 = NSLocalizedString(@"NAS_used_Space",nil);
|
|
|
+ NSString*title3 = @"100GB/1T";
|
|
|
+
|
|
|
+ NSString *fullTitle = [[NSString alloc] initWithFormat:@"%@ %@%@",title1,title2,title3];
|
|
|
+
|
|
|
+ NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:fullTitle];
|
|
|
+ NSRange redRange = NSMakeRange([fullTitle rangeOfString:title1].location, [fullTitle rangeOfString:title1].length);
|
|
|
+ UIColor *noteColor =[UIColor hwColor:@"#262626" alpha:1.0];
|
|
|
+ [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
|
|
|
+ [attrStr addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:16.0] range:redRange];
|
|
|
+
|
|
|
+ _titleLabel.attributedText = attrStr;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)setProgressFun
|
|
|
+{
|
|
|
+ CGRect frame = _progressBgView.bounds;
|
|
|
+ frame.size.width = frame.size.width * 0.5;
|
|
|
+
|
|
|
+ if (!isnan(frame.size.width))
|
|
|
+ {
|
|
|
+ _progressSelectView.frame = frame;
|
|
|
+ _glayer.frame = frame;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 按钮事件
|
|
|
+- (void)didClickButtonFun:(UIButton*)but
|
|
|
+{
|
|
|
+ NSInteger tag = but.tag;
|
|
|
+ HLog(@"%ld",tag);
|
|
|
+}
|
|
|
+@end
|