// // imageVersionRenewTipView.m // 隐私保护 // // Created by xd h on 2023/12/21. // #import "imageVersionRenewTipView.h" @interface imageVersionRenewTipView () @property (nonatomic,strong) UIView* whiteBgView; @property (nonatomic,strong) UIButton *updateNowBut; @property (nonatomic,strong) CAGradientLayer *gradientLayer; @property (nonatomic,strong) UILabel *tip1Lab; @end @implementation imageVersionRenewTipView - (id)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6]; [self drawAnyView]; return self; } - (void)drawAnyView{ _whiteBgView = [UIView new]; _whiteBgView.layer.cornerRadius = 8; _whiteBgView.backgroundColor = [UIColor whiteColor]; [self addSubview:_whiteBgView]; CGFloat curWhiteBgHeight = 320.f; ///获取设备当前地区的代码和APP语言环境 NSString *languageCode = [NSLocale preferredLanguages][0]; //目前支持 中文(简体 繁体) 英文 日语 if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound) { } else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound) { } else{ curWhiteBgHeight = 360; } [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(curWhiteBgHeight); //make.width.mas_equalTo(323.f*AUTOSCALE); make.width.mas_equalTo(323.f); make.centerY.mas_equalTo(0.f); make.centerX.mas_equalTo(0.f); }]; UIImageView *topImage = [[UIImageView alloc] init]; topImage.image = [UIImage imageNamed:@"imageVersionTipBg"]; [_whiteBgView addSubview:topImage]; [topImage mas_makeConstraints:^(MASConstraintMaker *make) { // make.height.mas_equalTo(244*AUTOSCALE); // make.width.mas_equalTo(323.f*AUTOSCALE); make.height.mas_equalTo(244); make.width.mas_equalTo(323.f); make.left.mas_equalTo(0.f); make.top.mas_equalTo(-40.f); }]; NSString *curTitleStr = NSLocalizedString(@"image_version_pop_title",nil); UILabel *titleLab = [[UILabel alloc] init]; titleLab.text = curTitleStr; titleLab.numberOfLines = 0; titleLab.textColor = [UIColor blackColor]; titleLab.font = [UIFont boldSystemFontOfSize:33.0]; [topImage addSubview:titleLab]; [titleLab mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(60); make.right.mas_equalTo(0.f); make.left.mas_equalTo(25.f); make.top.mas_equalTo(42.f); }]; NSString *curTip1Str = NSLocalizedString(@"image_version_pop_144_tip1",nil); NSString *curTipRedStr = NSLocalizedString(@"image_version_pop_144_tip1_2",nil); _tip1Lab = [[UILabel alloc] init]; //_tip1Lab.text = curTip1Str; _tip1Lab.numberOfLines = 0; //_tip1Lab.textAlignment = NSTextAlignmentCenter; _tip1Lab.textColor = [UIColor hwColor:@"#333333" alpha:1.0]; _tip1Lab.font = [UIFont systemFontOfSize:15.0]; [_whiteBgView addSubview:_tip1Lab]; //_tip1Lab.backgroundColor = [UIColor greenColor]; NSString *fullTitle = [[NSString alloc] initWithFormat:@"%@%@",curTip1Str,curTipRedStr]; NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:fullTitle]; NSRange rightRange = NSMakeRange([fullTitle rangeOfString:curTipRedStr].location, curTipRedStr.length); UIColor *rightColor =[UIColor hwColor:@"#FF2828" alpha:1.0]; [attrStr addAttribute:NSForegroundColorAttributeName value:rightColor range:rightRange]; // 设置行间距 NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setLineSpacing:5]; //设置行间距 [attrStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [fullTitle length])]; _tip1Lab.attributedText = attrStr; [_tip1Lab mas_makeConstraints:^(MASConstraintMaker *make) { //make.height.mas_equalTo(curHeight); make.right.mas_equalTo(-32.0); make.left.mas_equalTo(32.0); make.top.mas_equalTo(150); }]; _updateNowBut = [[UIButton alloc] init]; [_updateNowBut setTitle:NSLocalizedString(@"image_version_Update_Now",nil) forState:UIControlStateNormal]; //_updateNowBut.layer.cornerRadius = 8; //_updateNowBut.layer.masksToBounds = YES; [_updateNowBut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [_updateNowBut addTarget:self action:@selector(didClickUpdateFun) forControlEvents:UIControlEventTouchUpInside]; [_whiteBgView addSubview:_updateNowBut]; _gradientLayer = [CAGradientLayer layer]; _gradientLayer.frame = CGRectMake(0, 0, 268, 40); _gradientLayer.colors = @[(__bridge NSString *)[UIColor hwColor:@"#0CDEFD" alpha:1.0].CGColor, (__bridge NSString *)[UIColor hwColor:@"#058DFB" alpha:1.0].CGColor]; _gradientLayer.locations = @[@(0), @(1.0f)]; _gradientLayer.startPoint = CGPointMake(0, 0.5); _gradientLayer.endPoint = CGPointMake(0.97, 0.5); _gradientLayer.cornerRadius = 8; [_updateNowBut.layer addSublayer:_gradientLayer]; _updateNowBut.layer.shadowColor = [UIColor hwColor:@"#058DFB"].CGColor; // 设置阴影透明度(0.0到1.0) _updateNowBut.layer.shadowOpacity = 0.5; // 设置阴影偏移量(x, y) _updateNowBut.layer.shadowOffset = CGSizeMake(0, 3); // 设置阴影模糊半径 _updateNowBut.layer.shadowRadius = 5.0; // 为了使阴影在按钮外部可见,需要设置masksToBounds为NO // 注意:如果父视图设置了masksToBounds为YES,那么阴影可能仍然不可见 _updateNowBut.layer.masksToBounds = NO; [_updateNowBut mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(40.f); make.width.mas_equalTo(268.f); make.centerX.mas_equalTo(0.f); make.bottom.mas_equalTo(-30); }]; // UIButton *colseBut = [[UIButton alloc] init]; // [colseBut setImage:[UIImage imageNamed:@"common_del_white"] forState:UIControlStateNormal]; // [colseBut addTarget:self action:@selector(colseFun) forControlEvents:UIControlEventTouchUpInside]; // [self addSubview:colseBut]; // // [colseBut mas_makeConstraints:^(MASConstraintMaker *make) { // make.height.mas_equalTo(48); // make.width.mas_equalTo(48.f); // make.centerX.mas_equalTo(0.f); // make.top.mas_equalTo(_whiteBgView.mas_bottom).offset(30); // }]; } - (void)didClickUpdateFun { if(_didClickUpdateNowFun){ _didClickUpdateNowFun(); } } - (void)colseFun { NSString *datestr = [iTools getNowDateString]; [HWDataManager setObjectWithKey:Const_did_show_image_version_date value:datestr]; [self removeFromSuperview]; if(_didClickCloseFun){ _didClickCloseFun(); } } #pragma mark ota 镜像升级变化 //状态 -1=没有更新 0=下载中 1=下载完成 2=点击升级 3=宿主机代理导入容器镜像:进度条展示20% 4=导入容器镜像完成:进度条展示50% 5=宿主机代理创建容器镜像:进度条展示80% 6=容器镜像创建完成:进度条展示100% - (void)setStatus:(NSInteger)status{ if(status <= 1){ //默认是1的UI 不用处理 return; } CGFloat curWhiteBgHeight = 400.f; ///获取设备当前地区的代码和APP语言环境 NSString *languageCode = [NSLocale preferredLanguages][0]; //目前支持 中文(简体 繁体) 英文 日语 if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound) { } else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound) { } else{ curWhiteBgHeight = 520; } [_whiteBgView mas_updateConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(curWhiteBgHeight); }]; _updateNowBut.userInteractionEnabled = NO; _updateNowBut.layer.masksToBounds = YES; _updateNowBut.layer.shadowColor = [UIColor clearColor].CGColor; _updateNowBut.backgroundColor = [UIColor hwColor:@"#DADBDC"]; _updateNowBut.layer.cornerRadius = 8; CGFloat curProgress = 0.0; if(status == 2){ curProgress = 0.0; } else if(status == 3){ curProgress = 0.2; } else if(status == 4){ curProgress = 0.5; } else if(status == 5){ curProgress = 0.8; } else //if(status == 6) { curProgress = 1.0; } _gradientLayer.frame = CGRectMake(0, 0, 268*curProgress, 40); NSString *butNewTitleStr = [[NSString alloc] initWithFormat:@"%@%ld%%",NSLocalizedString(@"image_version_Update_ing",nil),(NSInteger)(curProgress*100)]; [_updateNowBut setTitle:butNewTitleStr forState:UIControlStateNormal]; NSString *leftStr = NSLocalizedString(@"image_version_pop_144_tip2_1",nil); NSString *rightStr = NSLocalizedString(@"image_version_pop_144_tip2_2",nil); NSString *totalStr = [[NSString alloc] initWithFormat:@"%@%@",leftStr,rightStr]; NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr]; NSRange redRange = NSMakeRange([totalStr rangeOfString:rightStr].location, [totalStr rangeOfString:rightStr].length); [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#FF2828" alpha:1.0] range:redRange]; //[noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15.0] range:redRange]; // 设置行间距 NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setLineSpacing:5]; //设置行间距 [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])]; _tip1Lab.attributedText = noteStr; } @end