123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- //
- // USBInsertPopView.m
- // 隐私保护
- //
- // Created by xd h on 2024/1/29.
- //
- #import "USBInsertPopView.h"
- #import <Lottie/Lottie.h>
- @interface USBInsertPopView ()
- @property (nonatomic,strong) UIView* whiteBgView;
- @property (nonatomic,copy) NSString* name;
- @end
- @implementation USBInsertPopView
- - (id)initWithFrame:(CGRect)frame withName:(NSString*)name{
- self = [super initWithFrame:frame];
- self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
- _name = name;
- [self drawAnyView];
-
- return self;
- }
- - (void)drawAnyView{
- _whiteBgView = [UIView new];
- _whiteBgView.layer.cornerRadius = 8;
- _whiteBgView.backgroundColor = [UIColor whiteColor];
- [self addSubview:_whiteBgView];
-
- [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(500 + safeArea + 20);
- make.left.mas_equalTo(0.f);
- make.right.mas_equalTo(0.f);
- make.bottom.mas_equalTo(20.f);
- }];
-
- NSString *titleRightStr = NSLocalizedString(@"disk_insertion_pop_title",nil);
- NSString *curTitleStr = [[NSString alloc] initWithFormat:@"[%@]%@",_name,titleRightStr];
- UILabel *titleLab = [[UILabel alloc] init];
- titleLab.text = curTitleStr;
- titleLab.textAlignment = NSTextAlignmentCenter;
- titleLab.numberOfLines = 0;
- titleLab.textColor = [UIColor blackColor];
- titleLab.font = [UIFont boldSystemFontOfSize:18.0];
- [_whiteBgView addSubview:titleLab];
-
- [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(20);
- make.right.mas_equalTo(0.f);
- make.left.mas_equalTo(25.f);
- make.top.mas_equalTo(20.f);
- }];
-
- NSString *curTip1Str = NSLocalizedString(@"disk_insertion_pop_tip",nil);
- UILabel *tip1Lab = [[UILabel alloc] init];
- tip1Lab.text = curTip1Str;
- tip1Lab.numberOfLines = 0;
- tip1Lab.textAlignment = NSTextAlignmentCenter;
- tip1Lab.textColor = [UIColor hwColor:@"#151515" alpha:0.5];
- tip1Lab.font = [UIFont systemFontOfSize:14.0];
- [_whiteBgView addSubview:tip1Lab];
-
- CGFloat curHeight = [curTip1Str boundingRectWithSize:CGSizeMake((SCREEN_W - 80), 1000) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0]} context:nil].size.height;
-
- curHeight += 15;
-
- [tip1Lab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(curHeight);
- make.right.mas_equalTo(-40.f);
- make.left.mas_equalTo(40.f);
- make.top.mas_equalTo(titleLab.mas_bottom).offset(10.f);
- }];
-
- LOTAnimationView *animation = [LOTAnimationView animationNamed:@"usbInsertAnimation"];
- animation.loopAnimation = YES;
- //animation.contentMode = UIViewContentModeScaleAspectFill;
- [_whiteBgView addSubview:animation];
- [animation playWithCompletion:^(BOOL animationFinished) {
- // Do Something
- }];
-
- CGFloat animationImageW = SCREEN_W - 15.0*2;
- CGFloat animationImageH = 232.0*animationImageW/343.0;
- [animation mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(animationImageH);
- make.width.mas_equalTo(animationImageW);
- make.left.mas_equalTo(15.f);
- make.top.mas_equalTo(tip1Lab.mas_bottom).offset(0);
- }];
-
- CGFloat imageW = SCREEN_W - 15.0*2;
- // CGFloat imageH = 184.0*imageW/343.0;
- //
- // UIImageView *topImage = [[UIImageView alloc] init];
- // topImage.image = [UIImage imageNamed:@"usb_pop_image"];
- // [_whiteBgView addSubview:topImage];
- //
- // [topImage mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.height.mas_equalTo(imageH);
- // make.width.mas_equalTo(imageW);
- // make.left.mas_equalTo(15.f);
- // make.top.mas_equalTo(tip1Lab.mas_bottom).offset(20);
- // }];
- //
- // NSString *subTip1 = NSLocalizedString(@"disk_insertion_pop_tip_sub1",nil);
- // NSString *subTip2 = NSLocalizedString(@"disk_insertion_pop_tip_sub2",nil);
- // NSString *subTip3 = NSLocalizedString(@"disk_insertion_pop_tip_sub3",nil);
- //
- // NSArray *titleArr = @[subTip1,subTip2,subTip3];
- // CGFloat labelSpace = 10.0;
- // CGFloat labelWidth = (imageW -20)/3.0;
- //
- // for (int i=0; i<titleArr.count; i++) {
- //
- // UILabel *subTipLab = [[UILabel alloc] init];
- // subTipLab.text = titleArr[i];
- // subTipLab.numberOfLines = 0;
- // subTipLab.textAlignment = NSTextAlignmentCenter;
- // subTipLab.textColor = [UIColor hwColor:@"##0A132B" alpha:1.0];
- // subTipLab.font = [UIFont systemFontOfSize:14.0];
- // [topImage addSubview:subTipLab];
- //
- // [subTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.height.mas_equalTo(40);
- // make.width.mas_equalTo(labelWidth);
- // make.left.mas_equalTo(i*(labelSpace + labelWidth));
- // make.bottom.mas_equalTo(0);
- // }];
- // }
-
- NSString *bottomTip1Str = NSLocalizedString(@"disk_insertion_pop_tip3",nil);
- UILabel *bottomTip1Lab = [[UILabel alloc] init];
- bottomTip1Lab.text = bottomTip1Str;
- bottomTip1Lab.textAlignment = NSTextAlignmentCenter;
- bottomTip1Lab.numberOfLines = 0;
- bottomTip1Lab.textColor = [UIColor hwColor:@"#151515" alpha:0.5];
- //bottomTip1Lab.font = [UIFont boldSystemFontOfSize:12.0];
- bottomTip1Lab.adjustsFontSizeToFitWidth = YES;
- [_whiteBgView addSubview:bottomTip1Lab];
-
- [bottomTip1Lab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(15);
- make.right.mas_equalTo(-15.f);
- make.left.mas_equalTo(15.f);
- make.top.mas_equalTo(animation.mas_bottom).offset(0.0);
- }];
-
- NSString *bottomTipStr = NSLocalizedString(@"disk_insertion_pop_tip2",nil);
- UILabel *bottomTipLab = [[UILabel alloc] init];
- bottomTipLab.text = bottomTipStr;
- //bottomTipLab.textAlignment = NSTextAlignmentCenter;
- bottomTipLab.numberOfLines = 0;
- bottomTipLab.textColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
- bottomTipLab.font = [UIFont boldSystemFontOfSize:12.0];
- [_whiteBgView addSubview:bottomTipLab];
-
- [bottomTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(50);
- make.right.mas_equalTo(-15.f);
- make.left.mas_equalTo(15.f);
- make.top.mas_equalTo(bottomTip1Lab.mas_bottom).offset(10.0);
- }];
- UIButton *konwBut = [[UIButton alloc] init];
- [konwBut setTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil) forState:UIControlStateNormal];
- konwBut.layer.cornerRadius = 8;
- konwBut.layer.masksToBounds = YES;
- [konwBut addTarget:self action:@selector(colseFun) forControlEvents:UIControlEventTouchUpInside];
- [_whiteBgView addSubview:konwBut];
-
- CAGradientLayer *gradientLayer = [CAGradientLayer layer];
- gradientLayer.startPoint = CGPointMake(0, 0.5);
- gradientLayer.endPoint = CGPointMake(0.97, 0.5);
- gradientLayer.frame = CGRectMake(0, 0, imageW, 48);
- 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)];
- [konwBut.layer addSublayer:gradientLayer];
-
- [konwBut mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(48);
- make.width.mas_equalTo(imageW);
- make.centerX.mas_equalTo(0.f);
- make.bottom.mas_equalTo(-(30 + safeArea));
- }];
-
- }
- - (void)colseFun
- {
- [self removeFromSuperview];
- }
- @end
|