// // shareRecordDetailsHWViewController.m // 双子星云手机 // // Created by xd h on 2024/5/15. // #import "shareRecordDetailsHWViewController.h" @interface shareRecordDetailsHWViewController () @property (nonatomic,strong)UILabel *shareTitleLabel; @property (nonatomic,strong)UILabel *shareBeginDateLabel; @property (nonatomic,strong)UIImageView *shareQRCodeImageView; @property (nonatomic,strong)UIButton*checkShareLinkButton; @property (nonatomic,strong)UILabel *shareEndDateLabel; @property (nonatomic,strong)UIButton*cancelShareLinkButton; @property (nonatomic,strong)UIButton*shareLinkCopyButton; @end @implementation shareRecordDetailsHWViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self.toolBar setHidden:YES]; [self.navigationBar setHidden:YES]; [self.navBarBGView setHidden:NO]; self.navBarBGView.backgroundColor = [UIColor whiteColor]; [self.view setBackgroundColor:[UIColor hwColor:@"#F5F7FA"]]; self.titleLabel.text = NSLocalizedString(@"share_record_title",nil); [self drawAnyView]; } - (void)drawAnyView{ // UIView *whiteBgView = [[UIView alloc] init]; whiteBgView.backgroundColor = [UIColor whiteColor]; [self.view addSubview:whiteBgView]; whiteBgView.layer.cornerRadius = 8; whiteBgView.layer.masksToBounds = YES; [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.right.mas_equalTo(-15); make.top.equalTo(self.navBarBGView.mas_bottom).offset(40.f); make.height.mas_equalTo(448); }]; //文件夹图标 UIImageView *folderImageView = [[UIImageView alloc] init]; folderImageView.image = [UIImage imageNamed:@"uploadFile_file_icon"]; folderImageView.backgroundColor = [UIColor whiteColor]; [self.view addSubview:folderImageView]; folderImageView.layer.cornerRadius = 44; folderImageView.layer.masksToBounds = YES; [folderImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f); make.centerX.mas_equalTo(self.view.mas_centerX); make.width.mas_equalTo(88); make.height.mas_equalTo(88); }]; _shareTitleLabel = [[UILabel alloc] init]; _shareTitleLabel.text = @"banner.png等多个文件"; _shareTitleLabel.textAlignment = NSTextAlignmentCenter; _shareTitleLabel.textColor = HW0A132BColor; _shareTitleLabel.font = [UIFont systemFontOfSize:14.0]; [whiteBgView addSubview:_shareTitleLabel]; [_shareTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(folderImageView.mas_bottom).offset(5.f); make.left.mas_equalTo(15); make.right.mas_equalTo(-15); make.height.mas_equalTo(20); }]; _shareBeginDateLabel = [[UILabel alloc] init]; _shareBeginDateLabel.text = @"2024/04/25 19:45"; _shareBeginDateLabel.textAlignment = NSTextAlignmentCenter; _shareBeginDateLabel.textColor = HW666666Color; _shareBeginDateLabel.font = [UIFont systemFontOfSize:12.0]; [whiteBgView addSubview:_shareBeginDateLabel]; [_shareBeginDateLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_shareTitleLabel.mas_bottom).offset(25.f); make.left.mas_equalTo(15); make.right.mas_equalTo(-15); make.height.mas_equalTo(15); }]; UIImageView *QRCodeEdgingImageView = [[UIImageView alloc] init]; QRCodeEdgingImageView.image = [UIImage imageNamed:@"share_QRCode_edging"]; [whiteBgView addSubview:QRCodeEdgingImageView]; [QRCodeEdgingImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_shareBeginDateLabel.mas_bottom).offset(10.f); make.centerX.mas_equalTo(self.view.mas_centerX); make.width.mas_equalTo(208); make.height.mas_equalTo(208); }]; _shareQRCodeImageView = [[UIImageView alloc] init]; _shareQRCodeImageView.backgroundColor = [UIColor greenColor]; [QRCodeEdgingImageView addSubview:_shareQRCodeImageView]; [_shareQRCodeImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(20); make.bottom.mas_equalTo(-20); make.left.mas_equalTo(20); make.right.mas_equalTo(-20); }]; _shareQRCodeImageView.image = [self generateQRCodeWithInputMessage:@"http://baidu.com" Width:168 Height:168]; _checkShareLinkButton = [[UIButton alloc] init]; [_checkShareLinkButton setTitle:NSLocalizedString(@"check_share_link_title",nil) forState:UIControlStateNormal]; [_checkShareLinkButton setTitleColor:[UIColor hwColor:@"#01B7EA"] forState:UIControlStateNormal]; _checkShareLinkButton.titleLabel.font = [UIFont systemFontOfSize:14.0]; [_checkShareLinkButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside]; _checkShareLinkButton.tag = 1; [self.view addSubview:_checkShareLinkButton]; [_checkShareLinkButton mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.right.mas_equalTo(-15); make.top.equalTo(QRCodeEdgingImageView.mas_bottom).offset(0.f); make.height.mas_equalTo(30); }]; _shareEndDateLabel = [[UILabel alloc] init]; _shareEndDateLabel.text = @"2024/04/25 19:45"; _shareEndDateLabel.textAlignment = NSTextAlignmentCenter; _shareEndDateLabel.textColor = HW0A132BColor; _shareEndDateLabel.font = [UIFont systemFontOfSize:14.0]; [whiteBgView addSubview:_shareEndDateLabel]; [_shareEndDateLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_checkShareLinkButton.mas_bottom).offset(25.f); make.left.mas_equalTo(15); make.right.mas_equalTo(-15); make.height.mas_equalTo(15); }]; _cancelShareLinkButton = [[UIButton alloc] init]; [_cancelShareLinkButton setTitle:NSLocalizedString(@"cancel_share_title",nil) forState:UIControlStateNormal]; [_cancelShareLinkButton setTitleColor:HW0A132BColor forState:UIControlStateNormal]; _cancelShareLinkButton.titleLabel.font = [UIFont systemFontOfSize:14.0]; [_cancelShareLinkButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside]; _cancelShareLinkButton.tag = 2; [self.view addSubview:_cancelShareLinkButton]; _cancelShareLinkButton.layer.cornerRadius = 8; _cancelShareLinkButton.layer.masksToBounds = YES; _cancelShareLinkButton.backgroundColor = [UIColor hwColor:@"#E3E8F1"]; [_cancelShareLinkButton mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.width.mas_equalTo(130); make.top.equalTo(whiteBgView.mas_bottom).offset(25); make.height.mas_equalTo(48); }]; _shareLinkCopyButton = [[UIButton alloc] init]; CGFloat w_btn = SCREEN_W-130 -15 -10 -15; // gradient CAGradientLayer *gl = [CAGradientLayer layer]; gl.frame = CGRectMake(0,0,w_btn,48.f); gl.startPoint = CGPointMake(0, 0.5); gl.endPoint = CGPointMake(1, 0.5); gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor]; gl.locations = @[@(0), @(1.0f)]; [_shareLinkCopyButton.layer addSublayer:gl]; [_shareLinkCopyButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; [_shareLinkCopyButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)]; [_shareLinkCopyButton setTitle:NSLocalizedString(@"copy_share_link_title",nil) forState:(UIControlStateNormal)]; [_shareLinkCopyButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]]; [_shareLinkCopyButton.layer setCornerRadius:8.f]; _shareLinkCopyButton.clipsToBounds = YES; _shareLinkCopyButton.tag = 11; [self.view addSubview:_shareLinkCopyButton]; [_shareLinkCopyButton mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-15); make.width.mas_equalTo(w_btn); make.top.equalTo(whiteBgView.mas_bottom).offset(25); make.height.mas_equalTo(48); }]; } // 生成二维码 - (UIImage *)generateQRCodeWithInputMessage:(NSString *)inputMessage Width:(CGFloat)width Height:(CGFloat)height{ NSData *inputData = [inputMessage dataUsingEncoding:NSUTF8StringEncoding]; CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"]; [filter setValue:inputData forKey:@"inputMessage"]; // [filter setValue:@"H" forKey:@"inputCorrectionLevel"]; // 设置二维码不同级别的容错率 CIImage *ciImage = filter.outputImage; // 消除模糊 CGFloat scaleX = MIN(width, height)/ciImage.extent.size.width; CGFloat scaleY = MIN(width, height)/ciImage.extent.size.height; ciImage = [ciImage imageByApplyingTransform:CGAffineTransformScale(CGAffineTransformIdentity, scaleX, scaleY)]; UIImage *returnImage = [UIImage imageWithCIImage:ciImage]; return returnImage; } - (void)didClickButtonFun:(UIButton*)but { } @end