| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- //
- // TFSheetView.m
- // IBOSSmini
- //
- // Created by guan hong hou on 2018/3/30.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "TFSheetView.h"
- #import "SheetViewCell.h"
- @interface TFSheetView()
- {
- UIView *_contentView;
- }
- @end
- @implementation TFSheetView
- - (id)initWithFrame:(CGRect)frame
- {
- if (self == [super initWithFrame:frame])
- {
- [self initContent];
- }
-
- return self;
- }
- - (void)initContent
- {
- self.frame = CGRectMake(0, 0,Screen_Width, Screen_Height);
-
- //alpha 0.0 白色 alpha 1 :黑色 alpha 0~1 :遮罩颜色,逐渐
- self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
- self.userInteractionEnabled = YES;
- [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disMissView)]];
-
- if (_contentView == nil)
- {
- _contentView = [[UIView alloc]initWithFrame:CGRectMake(0, Screen_Height - 300, Screen_Width, 300)];
- _contentView.backgroundColor = [UIColor whiteColor];
-
-
- [self addSubview:_contentView];
- _invoiceStyleTableView = [[UITableView alloc]
- initWithFrame:CGRectMake(0,
- 10,
- Screen_Width,
- 200)];
-
-
- _invoiceStyleTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
- _invoiceStyleTableView.backgroundColor = [UIColor whiteColor];
- _invoiceStyleTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _invoiceStyleTableView.delegate = self;
- _invoiceStyleTableView.dataSource=self;
- [_contentView addSubview:_invoiceStyleTableView];
-
- }}
- - (void)loadMaskView
- {
- }
- //展示从底部向上弹出的UIView(包含遮罩)
- - (void)showInView:(UIView *)view dataArry:(NSMutableArray*)dataList position:(NSInteger)pos
- {
- if (!view)
- {
- return;
- }
-
- [view addSubview:self];
- [view addSubview:_contentView];
- _position=pos;
- _dataArray=dataList;
- [_invoiceStyleTableView reloadData];
-
- [_contentView setFrame:CGRectMake(0, Screen_Height, Screen_Width, 300)];
-
- [UIView animateWithDuration:0.3 animations:^{
-
- self.alpha = 1.0;
-
- [_contentView setFrame:CGRectMake(0, Screen_Height - 300, Screen_Width, 300)];
-
- } completion:nil];
- }
- //移除从上向底部弹下去的UIView(包含遮罩)
- - (void)disMissView
- {
- [_contentView setFrame:CGRectMake(0, Screen_Height - 300, Screen_Width, 300)];
- [UIView animateWithDuration:0.3f
- animations:^{
-
- self.alpha = 0.0;
-
- [_contentView setFrame:CGRectMake(0, Screen_Height, Screen_Width, 300)];
- }
- completion:^(BOOL finished){
-
- [self removeFromSuperview];
- [_contentView removeFromSuperview];
-
- }];
-
- }
- #pragma mark - 委托回调函数
- #pragma mark - tableView回调
- /**
- 单元格cell个数
-
- @param tableView <#tableView description#>
- @param section <#section description#>
- @return <#return value description#>
- */
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [_dataArray count];
- }
- /**
- <#Description#>
-
- @param tableView <#tableView description#>
- @return <#return value description#>
- */
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- /**
- 每个单元格cell
-
- @param tableView <#tableView description#>
- @param indexPath <#indexPath description#>
- @return <#return value description#>
- */
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *cellIdentifier = @"InvoiceStyleCell";
- SheetViewCell *cell;
-
- cell=[[SheetViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
-
- //为单元格的label设置数据
- InvoiceStyle *invoiceStyle = [_dataArray objectAtIndex:indexPath.row];
- [cell setInvoiceStyle:invoiceStyle];
- return cell;
-
- }
- //行高
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- return 40;
- }
- /**
- 点击单元格事件
-
- @param tableView tableView description
- @param indexPath indexPath description
- */
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- InvoiceStyle *invoiceStyle = [_dataArray objectAtIndex:indexPath.row];
- __weak typeof(self) weakself=self;
- if ([weakself.delegate respondsToSelector:@selector(goElectronicInvoice:position:)]){
-
- [weakself.delegate goElectronicInvoice:invoiceStyle position:_position];
- }
- [self disMissView];
- }
- @end
|