// // MaskTestResultVC.m // GIGA // // Created by lianxiang on 2018/9/13. // Copyright © 2018年 com.giga.ios. All rights reserved. // #import "MaskTestResultVC.h" #import "MaskResultMinViewCell.h" #import "MaskResultPercentCell.h" #import "MaskResultShareViewCell.h" #import "GiGaFileNanager.h" @interface MaskTestResultVC () @end @implementation MaskTestResultVC - (void)viewDidLoad { [super viewDidLoad]; [self addNavTitile:@"测试结果"]; // Do any additional setup after loading the view. [self.view addSubview:self.tableView]; self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.backgroundColor = [UIColor whiteColor]; self.tableView.separatorStyle = UITableViewCellSelectionStyleNone; self.tableView.sectionFooterHeight = 0; self.tableView.estimatedSectionFooterHeight= 0; self.tableView.estimatedSectionHeaderHeight = 0; //self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width, 30)]; self.tableView.frame = CGRectMake(0,0,KMainW, self.view.frame.size.height); [self.tableView registerClass:[MaskResultPercentCell class] forCellReuseIdentifier:@"MaskResultPercentCell"]; [self.tableView registerClass:[MaskResultMinViewCell class] forCellReuseIdentifier:@"MaskResultMinViewCell"]; [self.tableView registerClass:[MaskResultShareViewCell class] forCellReuseIdentifier:@"MaskResultShareViewCell"]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 3; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row == 0) { static NSString *cellID = @"MaskResultPercentCell"; MaskResultPercentCell *cell =[tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[MaskResultPercentCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];; } [cell loadCellData:self.model]; return cell; }else if (indexPath.row == 1){ static NSString *cellID = @"MaskResultMinViewCell"; MaskResultMinViewCell *cell =[tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[MaskResultMinViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];; } [cell loadMineWith:self.model.minute]; return cell; }else if (indexPath.row == 2){ static NSString *cellID = @"MaskResultShareViewCell"; MaskResultShareViewCell *cell =[tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[MaskResultShareViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];; } [cell.shareBtn addTarget:self action:@selector(shareBtnAciton) forControlEvents:UIControlEventTouchUpInside]; [cell kidTitle:self.model.mask]; return cell; } return nil; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ CGFloat viewH = KMainH - SAFE_NAV_HEIGHT; CGFloat cellH = viewH / 3 ; return cellH; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 0.1; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 0.1; } -(void)shareBtnAciton{ UIImage *image = [self saveLongImage:self.tableView]; // SHareTestImageVC *imagevc = [[SHareTestImageVC alloc] init]; // imagevc.image = image; //[self.navigationController pushViewController:imagevc animated:YES]; } - (UIImage *)saveLongImage:(UITableView *)table { UIImage* image = nil; // 下面方法,第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果,需要传NO,否则传YES。第三个参数就是屏幕密度了,调整清晰度。 UIGraphicsBeginImageContextWithOptions(table.contentSize, YES, [UIScreen mainScreen].scale); CGPoint savedContentOffset = table.contentOffset; CGRect savedFrame = table.frame; table.contentOffset = CGPointZero; table.frame = CGRectMake(0, 0, table.contentSize.width, table.contentSize.height); [table.layer renderInContext: UIGraphicsGetCurrentContext()]; image = UIGraphicsGetImageFromCurrentImageContext(); table.contentOffset = savedContentOffset; table.frame = savedFrame; UIGraphicsEndImageContext(); [[GiGaFileNanager shareInstance] saveImaeToAlBum:image]; return image; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end