|
@@ -6,6 +6,12 @@
|
|
|
//
|
|
|
|
|
|
#import "fileTransferPopView.h"
|
|
|
+@interface fileTransferPopView ()
|
|
|
+{
|
|
|
+ UIButton *uploadButton;
|
|
|
+ UIButton *downButton;
|
|
|
+}
|
|
|
+@end
|
|
|
|
|
|
@implementation fileTransferPopView
|
|
|
|
|
@@ -32,17 +38,172 @@
|
|
|
make.bottom.mas_equalTo(10);
|
|
|
}];
|
|
|
|
|
|
- UIView *blackView = [[UIView alloc] init];
|
|
|
- whiteBgView.backgroundColor = [UIColor blackColor];
|
|
|
- whiteBgView.layer.cornerRadius = 2;
|
|
|
- [self addSubview:whiteBgView];
|
|
|
+ UIView *tapView = [[UIView alloc] init];
|
|
|
+ [self addSubview:tapView];
|
|
|
|
|
|
- [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ 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
|