// // JXInVaiteView.m // shiku_im // // Created by 123 on 2020/6/10. // Copyright © 2020 Reese. All rights reserved. // #import "JXInVaiteView.h" #import "UIViewExt.h" #import "UIView+LK.h" @interface JXInVaiteView() @end @implementation JXInVaiteView -(instancetype)initWithFrame:(CGRect)frame{ if ([super initWithFrame:frame]) { self.userInteractionEnabled=YES; //背景图片 UIImageView *backIMG=[[UIImageView alloc]init]; backIMG.image=[UIImage imageNamed:@"bgYaoq"]; backIMG.userInteractionEnabled=YES; backIMG.contentMode=UIViewContentModeScaleToFill; [self addSubview:backIMG]; [backIMG mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(JX_SCREEN_TOP); make.left.mas_equalTo(30); make.right.mas_equalTo(-30); make.bottom.mas_equalTo(-JX_SCREEN_TOP); }]; //滚动条 UIScrollView *imageScrollView =[[UIScrollView alloc]init]; imageScrollView.backgroundColor=[UIColor clearColor]; [backIMG addSubview:imageScrollView]; [imageScrollView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(0); make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(0); }]; UILabel *shareTitle=[[UILabel alloc]init]; shareTitle.text=@"分享邀请码"; shareTitle.textColor=[UIColor redColor]; shareTitle.textAlignment=NSTextAlignmentCenter; [imageScrollView addSubview:shareTitle]; shareTitle.frame = CGRectMake(20, 20, JX_SCREEN_WIDTH-80, 15); UIButton *closeBtn=[[UIButton alloc]init]; [closeBtn setTitle:@"x" forState:UIControlStateNormal]; [closeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [imageScrollView addSubview:closeBtn]; closeBtn.frame = CGRectMake(JX_SCREEN_WIDTH-100-1, 5, 30, 30); [closeBtn addTarget:self action:@selector(closeBtnclikc) forControlEvents:UIControlEventTouchUpInside]; UILabel *contentTitle=[[UILabel alloc]init]; contentTitle.text=@"您好,输入您的邀请码,点击\"下一步\" 系统将自动生成分享图片,请及时保存。"; contentTitle.numberOfLines=0; contentTitle.font=[UIFont systemFontOfSize:14 weight:UIFontWeightRegular]; [imageScrollView addSubview:contentTitle]; contentTitle.frame = CGRectMake(20, CGRectGetMaxY(shareTitle.frame)+20, JX_SCREEN_WIDTH-100, 50); UITextField *inviteTF=[[UITextField alloc]init]; inviteTF.placeholder=@"123456"; inviteTF.textAlignment=NSTextAlignmentCenter; inviteTF.backgroundColor=kRGBColor250; [imageScrollView addSubview:inviteTF]; self.yaoqinTF=inviteTF; inviteTF.frame = CGRectMake(20, CGRectGetMaxY(contentTitle.frame)+20, JX_SCREEN_WIDTH-100, 44); UIButton *nextBtn=[[UIButton alloc]init]; [nextBtn setTitle:@"下一步" forState:UIControlStateNormal]; [nextBtn setBackgroundImage:[UIImage imageNamed:@"anniu"] forState:UIControlStateNormal]; [imageScrollView addSubview:nextBtn]; self.nextBtn=nextBtn; nextBtn.frame = CGRectMake(((JX_SCREEN_WIDTH-60)-120)/2, CGRectGetMaxY(inviteTF.frame)+30, 120, 30); UIImageView *imageBackV=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"邀请码教程"]]; imageBackV.userInteractionEnabled=YES; [imageScrollView addSubview:imageBackV]; CGFloat imageYW = CGImageGetWidth(imageBackV.image.CGImage); // iamgeView的H = imageView的宽 / (原始图片的宽 / 原始图片的高)---根据宽高比得出imageView的宽 CGFloat imageH = (JX_SCREEN_WIDTH-80) / (imageYW / CGImageGetHeight(imageBackV.image.CGImage)); imageBackV.frame = CGRectMake(10, CGRectGetMaxY(nextBtn.frame)+30, JX_SCREEN_WIDTH-80, imageH); imageScrollView.contentSize=CGSizeMake(0, CGRectGetMaxY(imageBackV.frame)+30); long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; [g_server getact_getinviteget:salt andUserId:g_server.myself.userId andToView:self]; } return self; } #pragma mark --- 请求成功 -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{ [SVProgressHUD dismiss]; //N g(@"dict: %@ --- arry: %@",dict ,array1 ); if([aDownload.action isEqualToString:act_getinviteget]) { NSDictionary *dictM=dict; NSString *str=[NSString stringWithFormat:@"%@",dictM[@"invite"]]; self.yaoqinTF.text=str; } } -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{ [SVProgressHUD dismiss]; NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]]; if([errorCode isEqualToString:@"权限验证失败"]) { if ([aDownload.action isEqualToString:act_getinviteget]) { }else{ } } return [errorCode intValue]; } - (void)closeBtnclikc{ [self.yaoqinTF resignFirstResponder]; self.hidden=YES; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [self endEditing:YES]; } @end