123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- //
- // fileTransferPopView.m
- // 隐私保护
- //
- // Created by xd h on 2023/12/27.
- //
- #import "fileTransferPopView.h"
- @interface fileTransferPopView ()
- {
- UIButton *uploadButton;
- UIButton *downButton;
- }
- @end
- @implementation fileTransferPopView
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
-
- [self drawAnyView];
-
- return self;
- }
- - (void)drawAnyView{
- [self setBackgroundColor:[UIColor hwColor:@"#000000" alpha:0.6]];
-
- UIView *whiteBgView = [[UIView alloc] init];
- whiteBgView.backgroundColor = [UIColor whiteColor];
- whiteBgView.layer.cornerRadius = 12;
- [self addSubview:whiteBgView];
-
- [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(237+ 10);
- make.bottom.mas_equalTo(10);
- }];
-
- UIView *tapView = [[UIView alloc] init];
- [self addSubview:tapView];
-
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapUpFun:)];
- [tapView addGestureRecognizer:tap];
-
- [tapView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(0);
- make.bottom.mas_equalTo(whiteBgView.mas_top);
- }];
-
- UIView *blackView = [[UIView alloc] init];
- blackView.backgroundColor = [UIColor blackColor];
- blackView.layer.cornerRadius = 2;
- [whiteBgView addSubview:blackView];
- [blackView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(40);
- make.height.mas_equalTo(4);
- make.centerX.mas_equalTo(0);
- make.top.mas_equalTo(8);
- }];
-
- CGFloat butW = SCREEN_W - 15*2;
- CGFloat butH = butW * 80.0/345.0;
-
- //
- uploadButton = [[UIButton alloc] init];
- [uploadButton setBackgroundImage:[UIImage imageNamed:@"uploadFile_bg_upload"] forState:UIControlStateNormal];
- uploadButton.tag = 1;
- [uploadButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- [whiteBgView addSubview:uploadButton];
-
- [uploadButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(butW);
- make.height.mas_equalTo(butH);
- make.centerX.mas_equalTo(0);
- make.top.mas_equalTo(blackView.mas_bottom).offset(10);
- }];
-
-
-
- downButton = [[UIButton alloc] init];
- downButton.tag = 2;
- [downButton setBackgroundImage:[UIImage imageNamed:@"uploadFile_bg_downLoad"] forState:UIControlStateNormal];
- [downButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- [whiteBgView addSubview:downButton];
-
- [downButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(butW);
- make.height.mas_equalTo(butH);
- make.centerX.mas_equalTo(0);
- make.top.mas_equalTo(uploadButton.mas_bottom).offset(15);
- }];
- }
- - (void)setFileTransferType:(NSInteger)fileTransferType
- {
- _fileTransferType = fileTransferType;
-
- NSString *uploadTitle = NSLocalizedString(@"File_upload_type_image",nil);
- NSString *uploadTip = NSLocalizedString(@"File_upload_type_tip",nil);
-
- NSString *downloadTitle = NSLocalizedString(@"File_down_type_image",nil);
- NSString *downloadTip = NSLocalizedString(@"File_down_type_tip",nil);
-
- if(fileTransferType == 2)
- {
- uploadTitle = NSLocalizedString(@"File_upload_type_video",nil);
- downloadTitle = NSLocalizedString(@"File_down_type_video",nil);
- }
-
- UILabel *uploadLabel = [[UILabel alloc] init];
- uploadLabel.textColor = [UIColor whiteColor];
- uploadLabel.font = [UIFont boldSystemFontOfSize:18.0];
- uploadLabel.numberOfLines = 0;
- [uploadButton addSubview:uploadLabel];
-
- NSString *totalStr = [[NSString alloc] initWithFormat:@"%@\n%@",uploadTitle,uploadTip];
-
- NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
-
- NSRange redRange = NSMakeRange([totalStr rangeOfString:uploadTip].location, [totalStr rangeOfString:uploadTip].length);
- [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#FFFFFF" alpha:0.8] range:redRange];
- [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:redRange];
- // 设置行间距
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle setLineSpacing:5]; //设置行间距
-
- [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
-
- uploadLabel.attributedText = noteStr;
-
- [uploadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
-
- UILabel *downloadLabel = [[UILabel alloc] init];
- downloadLabel.textColor = [UIColor whiteColor];
- downloadLabel.font = [UIFont boldSystemFontOfSize:18.0];
- downloadLabel.numberOfLines = 0;
- [downButton addSubview:downloadLabel];
-
- NSString *downTotalStr = [[NSString alloc] initWithFormat:@"%@\n%@",downloadTitle,downloadTip];
-
- NSMutableAttributedString *downNoteStr = [[NSMutableAttributedString alloc] initWithString:downTotalStr];
-
- NSRange downredRange = NSMakeRange([downTotalStr rangeOfString:downloadTip].location, [downTotalStr rangeOfString:downloadTip].length);
- [downNoteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#FFFFFF" alpha:0.8] range:downredRange];
- [downNoteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:downredRange];
- // 设置行间距
- // NSMutableParagraphStyle *paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
- // [paragraphStyle1 setLineSpacing:5]; //设置行间距
-
- [downNoteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [downTotalStr length])];
-
- downloadLabel.attributedText = downNoteStr;
-
- [downloadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.bottom.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
- }
- - (void)tapUpFun:(UITapGestureRecognizer*)tap
- {
- [self removeFromSuperview];
- }
- - (void)didClickButtonFun:(UIButton*)button
- {
- [self tapUpFun:nil];
-
- NSInteger tag = button.tag;
-
- NSInteger didTag = -1;
-
- if(_fileTransferType == 1){
- if(tag == 1){
- didTag = 11;
- }
- else if(tag == 2){
- didTag = 12;
- }
- }
- else if(_fileTransferType == 2){
- if(tag == 1){
- didTag = 21;
- }
- else if(tag == 2){
- didTag = 22;
- }
- }
-
- if(didTag){
- if(_didClickBut)
- {
- _didClickBut(didTag);
- }
- }
- }
- @end
|