// // KXMainHomeViewContronller.m // QBCS // // Created by qianbodong on 2017/7/28. // Copyright © 2017年 kuxuan. All rights reserved. // #import "KXMainHomeViewContronller.h" #import "KXThirdWebViewController.h" #import "KXSelectTableViewCell.h" #import "KXLogginViewController.h" #import "KXMainWaitBGView.h" #import #import @interface KXMainHomeViewContronller () { UIView *_selectView; // BOOL _selected; } @property (nonatomic,strong)UITableView *selectTableView; @property (nonatomic,strong)NSArray *monthArray; @property (nonatomic,assign)NSInteger month; @property (nonatomic,assign)BOOL agreeBool; @property (nonatomic,strong)UIView *topView; @property (nonatomic,strong)UIView *backView; @property (nonatomic,strong)NSArray *protocolArray; @end @implementation KXMainHomeViewContronller - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self createllView]; [self createllSelectView]; // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeView:) name:KXWAITING object:nil]; self.agreeBool=YES; [self addViews]; } -(void)addViews{ [self.view addSubview:self.backView]; [self.view addSubview:self.topView]; self.topView.hidden=YES; self.backView.hidden=YES; } -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationController.navigationBar.hidden=YES; [self checkLog]; } -(void)createllView{ self.navigationController.navigationBar.hidden=YES; // [self setTitle:@"财神借钱"]; // [(UILabel*)[self.navigationItem titleView] setTextColor:[UIColor whiteColor]]; self.view.backgroundColor=[UIColor background]; UIView* viewHeader=[[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 170*SCREEN_MUTI)]; viewHeader.backgroundColor=[UIColor baseColor]; [self.view addSubview:viewHeader]; UILabel* titleLable=[[UILabel alloc]initWithFrame:CGRectMake(0,20, SCREEN_WIDTH, 40)]; titleLable.textColor=[UIColor whiteColor]; titleLable.textAlignment=NSTextAlignmentCenter; titleLable.font=[UIFont boldSystemFontOfSize:17]; titleLable.text=@"借贷申请"; [viewHeader addSubview:titleLable]; UILabel* la=[[UILabel alloc]init]; [la setBackgroundColor:[UIColor baseColor]]; la.text=@"5000.00"; la.tag=8800; la.textColor=[UIColor whiteColor]; la.textAlignment = NSTextAlignmentCenter; la.font=FONT_BOLD(28); [viewHeader addSubview:la]; UILabel* titleYuan=[[UILabel alloc]init]; titleYuan.textColor=[UIColor whiteColor]; titleYuan.textAlignment=NSTextAlignmentCenter; titleYuan.font=[UIFont boldSystemFontOfSize:12]; titleYuan.text=@"申请金额(元)"; [viewHeader addSubview:titleYuan]; [la mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(viewHeader); make.centerY.equalTo(viewHeader).offset(20); }]; [titleYuan mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(la.mas_bottom).offset(8*SCREEN_MUTI); make.centerX.equalTo(viewHeader); }]; UIView* view=[[UIView alloc]initWithFrame:CGRectMake(0, 170*SCREEN_MUTI, SCREEN_WIDTH/2, 70*SCREEN_MUTI)]; [view setBackgroundColor:[UIColor baseColor]]; [self.view addSubview:view]; UILabel* labelTitle1=[[UILabel alloc] init]; labelTitle1.textColor=[UIColor whiteColor]; // labelTitle1.textAlignment=NSTextAlignmentCenter; labelTitle1.font=FONT_SYS(10); labelTitle1.text=@"每月还款金额"; [view addSubview:labelTitle1]; UILabel* labelTotal=[[UILabel alloc] init]; labelTotal.textColor=[UIColor whiteColor]; labelTotal.font=FONT_BOLD(19); // labelTotal.backgroundColor=[UIColor redColor]; labelTotal.text=@"221.60"; labelTotal.tag=8801; [view addSubview:labelTotal]; UILabel* labelYuan=[[UILabel alloc] init]; labelYuan.textColor=[UIColor whiteColor]; labelYuan.font=FONT_SYS(12); labelYuan.text=@"(¥)"; // labelYuan.backgroundColor=[UIColor redColor]; [view addSubview:labelYuan]; CGFloat height1=[labelTitle1.text boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:labelTitle1.font} context:nil].size.height; CGFloat height2=[labelTotal.text boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:labelTotal.font} context:nil].size.height; CGFloat width=[labelYuan.text boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:labelYuan.font} context:nil].size.width; [labelTitle1 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(view.mas_top).offset((62*SCREEN_MUTI-height1-height2)/2); make.centerX.equalTo(view); }]; [labelTotal mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(labelTitle1.mas_bottom).offset(8*SCREEN_MUTI); make.centerX.equalTo(view).offset(-width/2); }]; [labelYuan mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(labelTotal.mas_right); make.bottom.equalTo(labelTotal.mas_bottom).offset(-2); }]; view=[[UIView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2, 170*SCREEN_MUTI, SCREEN_WIDTH/2, 70*SCREEN_MUTI)]; [view setBackgroundColor:[UIColor baseColor]]; [self.view addSubview:view]; labelTitle1=[[UILabel alloc] init]; labelTitle1.textColor=[UIColor whiteColor]; labelTitle1.font=FONT_SYS(10); labelTitle1.text=@"还款期数"; [view addSubview:labelTitle1]; labelTotal=[[UILabel alloc] init]; labelTotal.textColor=[UIColor whiteColor]; labelTotal.font=FONT_BOLD(19); labelTotal.text=@"24"; labelTotal.tag=8802; [view addSubview:labelTotal]; labelYuan=[[UILabel alloc] init]; labelYuan.textColor=[UIColor whiteColor]; labelYuan.font=FONT_SYS(12); labelYuan.text=@"(月)"; [view addSubview:labelYuan]; UIView* lin=[[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2,180*SCREEN_MUTI, 1, 50*SCREEN_MUTI)]; [lin setBackgroundColor:[UIColor whiteColor]]; [self.view addSubview:lin]; CGFloat width1=[labelYuan.text boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:labelYuan.font} context:nil].size.width; [labelTitle1 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(view.mas_top).offset((62*SCREEN_MUTI-height1-height2)/2); make.centerX.equalTo(view); }]; [labelTotal mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(labelTitle1.mas_bottom).offset(8*SCREEN_MUTI); make.centerX.equalTo(view).offset(-width1/2); }]; [labelYuan mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(labelTotal.mas_right); make.bottom.equalTo(labelTotal.mas_bottom).offset(-2); }]; UILabel* labelAll=[[UILabel alloc] init]; labelAll.textColor=[UIColor titleColor]; labelAll.font=FONT_SYS(16); labelAll.text=@"借款金额"; CGSize size=[labelAll.text boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:labelAll.font} context:nil].size; view=[[UIView alloc]initWithFrame:CGRectMake(14*SCREEN_MUTI, 240*SCREEN_MUTI, SCREEN_WIDTH-28*SCREEN_MUTI, 142*SCREEN_MUTI+size.height*2-40)]; view.layer.cornerRadius=2; view.layer.masksToBounds=YES; view.backgroundColor=[UIColor whiteColor]; view.layer.borderWidth = SCREEN_MUTI; view.layer.borderColor =[[UIColor lineColor1]CGColor]; view.tag=8888; [self.view addSubview:view]; [view addSubview:labelAll]; UITextField* textAll=[[UITextField alloc] init]; textAll.textColor=[UIColor titleColor]; textAll.font=FONT_SYS(16); textAll.placeholder=@"请输入金额"; textAll.tag=8865; textAll.keyboardType = UIKeyboardTypeNumberPad; textAll.delegate=self; [view addSubview:textAll]; UILabel* labelAll1=[[UILabel alloc] init]; labelAll1.textColor=[UIColor titleColor]; labelAll1.font=FONT_SYS(16); labelAll1.text=@"元"; [view addSubview:labelAll1]; CGFloat width2=[labelAll1.text boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:labelAll1.font} context:nil].size.width; lin=[[UIView alloc] init]; [lin setBackgroundColor:[UIColor lineColor1]]; [view addSubview:lin]; [labelAll mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(view.mas_top).offset(31*SCREEN_MUTI); make.left.equalTo(view.mas_left).offset(27*SCREEN_MUTI); make.width.mas_equalTo(size.width); }]; [labelAll1 mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(view.mas_right).offset(-26*SCREEN_MUTI); make.bottom.equalTo(labelAll.mas_bottom); make.width.mas_equalTo(width2); }]; [textAll mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(labelAll.mas_right).offset(10*SCREEN_MUTI); make.right.equalTo(labelAll1.mas_left); make.bottom.equalTo(labelAll.mas_bottom); }]; [lin mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(labelAll.mas_right); make.right.equalTo(labelAll1.mas_left); make.top.equalTo(labelAll.mas_bottom); make.height.mas_equalTo(1); }]; labelAll=[[UILabel alloc] init]; labelAll.textColor=[UIColor titleColor]; labelAll.font=FONT_SYS(16); labelAll.text=@"借款期数"; [view addSubview:labelAll]; UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom]; [button setTitle:@"请选择期数" forState:UIControlStateNormal]; // button.backgroundColor=[UIColor redColor]; button.titleLabel.font=FONT_SYS(16); button.tag=8866; button.titleEdgeInsets= UIEdgeInsetsMake(0, 0, -10, 0); [button addTarget:self action:@selector(buttonllAction:) forControlEvents:UIControlEventTouchUpInside]; button.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft; [button setTitleColor:[UIColor baseColor] forState:UIControlStateNormal]; [view addSubview:button]; labelAll1=[[UILabel alloc] init]; labelAll1.textColor=[UIColor titleColor]; labelAll1.font=FONT_SYS(16); labelAll1.text=@"月"; [view addSubview:labelAll1]; lin=[[UIView alloc] init]; [lin setBackgroundColor:[UIColor lineColor1]]; // [lin setBackgroundColor:[UIColor redColor]]; [view addSubview:lin]; UIButton *agreeButton=[UIButton buttonWithType:UIButtonTypeCustom]; agreeButton.frame=CGRectMake(0, 0, 16, 16); agreeButton.tag=2000; [agreeButton addTarget:self action:@selector(agreeAction:) forControlEvents:UIControlEventTouchUpInside]; agreeButton.selected=YES; [agreeButton setImage:[UIImage imageNamed:@"disagree_protocol"] forState:UIControlStateNormal]; [agreeButton setImage:[UIImage imageNamed:@"agree_protocol"] forState:UIControlStateSelected]; UIView *protocolView=[[UIView alloc]init]; protocolView.frame=CGRectMake(0, 0, 240, 20); for (int i=0; i<3; i++) { UIButton *button=[[UIButton alloc]init]; button.titleLabel.font=[UIFont systemFontOfSize:12.0f]; [button addTarget:self action:@selector(protocolAction:) forControlEvents:UIControlEventTouchUpInside]; [button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal]; button.tag=1000+i; switch (i) { case 0: { [button setTitle:@"《委托授权协议》" forState:UIControlStateNormal]; button.frame=CGRectMake(0, -3, 100, 20); } break; case 1: { [button setTitle:@"《借款协议》" forState:UIControlStateNormal]; button.frame=CGRectMake(90, -3, 65, 20); } break; case 2: { [button setTitle:@"《平台服务协议》" forState:UIControlStateNormal]; button.frame=CGRectMake(90+65, -3, 70, 20); } break; default: break; } [button sizeToFit]; [protocolView addSubview:button]; } // protocolView.backgroundColor=[UIColor redColor]; UITextField *protocolText=[[UITextField alloc]init]; protocolText.text=@"同意"; protocolText.font = [UIFont systemFontOfSize:12.0]; protocolText.textAlignment=NSTextAlignmentCenter; protocolText.leftView=agreeButton; protocolText.leftViewMode=UITextFieldViewModeAlways; protocolText.rightView=protocolView; protocolText.rightViewMode=UITextFieldViewModeAlways; [self.view addSubview:protocolText]; [labelAll mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(view.mas_top).offset(71*SCREEN_MUTI+size.height); make.left.equalTo(view.mas_left).offset(27*SCREEN_MUTI); }]; [labelAll1 mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(view.mas_right).offset(-26*SCREEN_MUTI); make.bottom.equalTo(labelAll.mas_bottom); }]; [button mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(labelAll.mas_bottom); make.left.equalTo(labelAll.mas_right).offset(10*SCREEN_MUTI); make.right.equalTo(labelAll1.mas_left); }]; [lin mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(labelAll.mas_right); make.right.equalTo(labelAll1.mas_left); make.top.equalTo(labelAll.mas_bottom); make.height.mas_equalTo(1); }]; [protocolText mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(240+16+45);// make.height.mas_equalTo(20); make.top.equalTo(view.mas_bottom).offset(10); make.left.equalTo(view.mas_left); }]; UIView * views=[[UIView alloc]initWithFrame:CGRectMake(18, 0, 45, 16)]; views.backgroundColor=[UIColor clearColor]; [protocolText addSubview:views]; UIButton *next=[UIButton buttonWithType:UIButtonTypeCustom]; // next.frame=CGRectMake(14*SCREEN_MUTI,(130+11+306+26)*SCREEN_MUTI, SCREEN_WIDTH-28*SCREEN_MUTI, 44*SCREEN_MUTI); next.layer.cornerRadius=3; next.tag=999; next.layer.masksToBounds=YES; next.backgroundColor=[UIColor baseColor]; next.titleLabel.font=FONT_SYS(16); [next setTitle:@"申请贷款" forState:UIControlStateNormal]; [next setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [next addTarget:self action:@selector(nextAction) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:next]; [next mas_makeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(view.mas_bottom).offset(80*SCREEN_MUTI); make.bottom.equalTo(self.view.mas_bottom).offset(-80*SCREEN_MUTI); make.left.equalTo(view.mas_left); make.right.equalTo(view.mas_right); make.height.mas_equalTo(44*SCREEN_MUTI); }]; UILabel *littleLabel=[[UILabel alloc]init]; littleLabel.text=@"由南宁市海源小额贷款有限公司出品为您提供高品质金融服务"; littleLabel.textColor=[UIColor detailTitleColor]; littleLabel.textAlignment=NSTextAlignmentCenter; littleLabel.font=FONT_SYS(11); [self.view addSubview:littleLabel]; [littleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(next.mas_centerX); make.top.equalTo(next.mas_bottom).offset(5); }]; } -(void)agreeAction:(UIButton *)sender{ self.agreeBool=!self.agreeBool; sender.selected=self.agreeBool; } -(void)protocolAction:(UIButton *)sender{ self.backView.hidden=NO; self.topView.hidden=NO; long indexSender=sender.tag-1000; UILabel *titleLabel=[self.topView viewWithTag:764]; titleLabel.text=sender.titleLabel.text; UIWebView *content=[self.topView viewWithTag:766]; content.delegate = self; NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWithPath:path]; NSString * htmlPath = [[NSBundle mainBundle] pathForResource:self.protocolArray[indexSender][@"html"] ofType:@"html"]; // NSLog(@"--%@--%@--",self.protocolArray[indexSender][@"html"],htmlPath); NSString * htmlCont = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil]; [content loadHTMLString:htmlCont baseURL:baseURL]; } -(void)createllSelectView { _month=0; _selectView=[[UIView alloc]initWithFrame:self.view.bounds]; _selectView.hidden=YES; _selectView.backgroundColor=[UIColor colorWithWhite:0 alpha:0.5]; [self.view addSubview:_selectView]; UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenAction:)]; tapGesturRecognizer.delegate = self; [_selectView addGestureRecognizer:tapGesturRecognizer]; self.selectTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,SCREEN_HEIGHT-220-49, SCREEN_WIDTH, 220) style:UITableViewStylePlain]; self.selectTableView.separatorStyle=UITableViewCellSeparatorStyleNone; [self.selectTableView registerClass:[KXSelectTableViewCell class] forCellReuseIdentifier:@"selected"]; self.selectTableView.tableFooterView=[[UIView alloc]init]; self.selectTableView.delegate = self; self.selectTableView.dataSource = self; [_selectView addSubview:self.selectTableView]; } -(void)hiddenAction:(UITapGestureRecognizer*) g{ _selectView.hidden=YES; } - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{ CGPoint point = [gestureRecognizer locationInView:_selectView]; if(point.y8) { return NO; } if([self isPureInt:string]){ if(range.location==0&&[string hasPrefix:@"0"]){ return NO; } }else{ if(string.length!=0){ return NO; } } return YES; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 6; } -(NSArray *)monthArray { if (!_monthArray) { _monthArray=@[@"1",@"3",@"6",@"12",@"24",@"36"]; } return _monthArray; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { KXSelectTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"selected"]; if (!cell) { cell=[[KXSelectTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"selected"]; } cell.detailStr=self.monthArray[indexPath.row]; return cell; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { return 45; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { _month=[self.monthArray[indexPath.row] integerValue]; UIButton *button=[self.view viewWithTag:8866]; [button setTitle:self.monthArray[indexPath.row] forState:UIControlStateNormal]; UILabel* label=(UILabel*)[self.view viewWithTag:8802]; label.text=self.monthArray[indexPath.row]; UITextField* text=(UITextField*)[self.view viewWithTag:8865]; if(text.text.length==0){ [self calculate: 5000]; }else{ [self calculate: text.text.integerValue]; } _selectView.hidden=YES; } -(void)buttonllAction:(UIButton *)btn{ // [self.selectTableView reloadData]; _selectView.hidden=NO; } -(void)nextAction { UIButton *nextBtn=[self.view viewWithTag:999]; nextBtn.enabled=NO; // if ([nextBtn.titleLabel.text isEqualToString:@"审核中..."]) { // [self createPromptWhit:@"不要着急,请耐心等待审核......"]; // return; // } NSString *urlString=[NSString stringWithFormat:@"%@/user/personalCenter",URL]; [KXHTTP post:urlString params:nil success:^(id json) { NSString *username= [[NSUserDefaults standardUserDefaults]valueForKey:USER_NAME]; NSString *password=[[NSUserDefaults standardUserDefaults]valueForKey:USER_PASSWORD]; if (!username||!password) { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请登录" preferredStyle:UIAlertControllerStyleAlert]; [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { KXLogginViewController *loggin=[[KXLogginViewController alloc]init]; self.navigationController.navigationBar.hidden = NO; [self.navigationController pushViewController:loggin animated:YES]; [[NSUserDefaults standardUserDefaults]setObject:nil forKey:@"ISPOP"]; [[NSUserDefaults standardUserDefaults]synchronize]; }]]; [self presentViewController:alertController animated:YES completion:nil]; nextBtn.enabled=YES; }else if (!self.agreeBool){//请勾选同意协议 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请勾选同意协议" preferredStyle:UIAlertControllerStyleAlert]; [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [[NSUserDefaults standardUserDefaults]setObject:nil forKey:@"ISPOP"]; [[NSUserDefaults standardUserDefaults]synchronize]; }]]; [self presentViewController:alertController animated:YES completion:nil]; nextBtn.enabled=YES; }else{ UITextField* textfield=[self.view viewWithTag:8865]; if(textfield.text.length==0){ [self createPromptWhit:@"请输入金额后再试"]; nextBtn.enabled=YES; return; } if(_month==0){ [self createPromptWhit:@"请选择期限后再试"]; nextBtn.enabled=YES; return; } KXThirdWebViewController *mainWeb=[[KXThirdWebViewController alloc]init]; mainWeb.amount=textfield.text.integerValue ; mainWeb.term=_month; [self.navigationController pushViewController:mainWeb animated:YES]; nextBtn.enabled=YES; } } failure:^(NSError *error) { nextBtn.enabled=YES; }]; } -(void)createPromptWhit:(NSString*) message{ UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:message preferredStyle:UIAlertControllerStyleAlert]; [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]]; [self presentViewController:alertController animated:YES completion:nil]; } -(void)closeTop{ self.topView.hidden=YES; self.backView.hidden=YES; UIWebView *content=[self.topView viewWithTag:766]; [content loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]]; } -(UIView *)topView{ if (!_topView) { _topView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 380)]; _topView.center=self.view.center; _topView.backgroundColor=[UIColor whiteColor]; UILabel *titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 300, 49.5)]; titleLabel.textColor=[UIColor baseColor]; titleLabel.textAlignment=NSTextAlignmentCenter; UIView *line1=[[UIView alloc]initWithFrame:CGRectMake(0, 49.5, 300, 0.5)]; line1.backgroundColor=[UIColor baseColor]; UIView *line2=[[UIView alloc]initWithFrame:CGRectMake(0, 330, 300, 0.5)]; line2.backgroundColor=[UIColor baseColor]; titleLabel.tag=764; // UIScrollView *contentScrollView=[[UIScrollView alloc]initWithFrame:]; // contentScrollView.tag=765; UIWebView*content=[[UIWebView alloc]initWithFrame:CGRectMake(0, 50, 300, 280)]; content.tag=766; UIButton *closeButton=[[UIButton alloc]initWithFrame:CGRectMake(0, 330.5, 300, 50)]; content.backgroundColor=[UIColor whiteColor]; [closeButton setTitle:@"关闭" forState:UIControlStateNormal]; [closeButton setTitleColor:[UIColor baseColor] forState:UIControlStateNormal]; [closeButton addTarget:self action:@selector(closeTop) forControlEvents:UIControlEventTouchUpInside]; closeButton.tag=767; [_topView addSubview:titleLabel]; // [contentScrollView addSubview:content]; // [_topView addSubview:contentScrollView]; [_topView addSubview:content]; [_topView addSubview:closeButton]; [_topView addSubview:line1]; [_topView addSubview:line2]; } return _topView; } -(UIView *)backView{ if (!_backView) { _backView=[[UIView alloc]initWithFrame:self.view.bounds]; _backView.backgroundColor=[UIColor KXColorWithHex:0x000000 alpha:0.3]; } return _backView; } -(NSArray *)protocolArray{ if (!_protocolArray) { NSMutableArray *arr=[NSMutableArray array]; NSString*path=[[NSBundle mainBundle] pathForResource:@"protocolList" ofType:@"plist"]; NSMutableArray *dataList=[NSMutableArray arrayWithContentsOfFile:path]; for (NSDictionary *dic in dataList) { [arr addObject:dic]; } _protocolArray=[NSArray arrayWithArray:arr]; } return _protocolArray; } @end