117 lines
3.4 KiB
Objective-C
117 lines
3.4 KiB
Objective-C
//
|
|
// MaskTimeShareActionSheet.m
|
|
// GIGA
|
|
//
|
|
// Created by lianxiang on 2018/9/22.
|
|
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
|
//
|
|
|
|
#import "MaskTimeShareActionSheet.h"
|
|
#import "MaskActionSheetViewCell.h"
|
|
|
|
@interface MaskTimeShareActionSheet()<UITableViewDelegate,UITableViewDataSource>
|
|
@property(nonatomic,strong) UITableView *tabview;
|
|
@end
|
|
|
|
@implementation MaskTimeShareActionSheet
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3]; ;
|
|
[self creatUI];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)creatUI{
|
|
|
|
|
|
|
|
UIView *holdview =[[UIView alloc] init];
|
|
holdview.frame =CGRectMake(0,KMainH - 216 - 60 -20 , KMainW, 216 + 60 +20);
|
|
holdview.backgroundColor = [UIColor whiteColor];
|
|
// CGRect backRect= holdview.frame;
|
|
//
|
|
// UIBezierPath *maskPath=[UIBezierPath bezierPathWithRoundedRect:backRect byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(15, 15)];
|
|
// CAShapeLayer *maskLayer =[[CAShapeLayer alloc] init];
|
|
// maskLayer.frame = backRect;
|
|
// maskLayer.path = maskPath.CGPath;
|
|
// holdview.layer.mask = maskLayer;
|
|
holdview.layer.masksToBounds = YES;
|
|
holdview.layer.cornerRadius = 10;
|
|
[self addSubview:holdview];
|
|
|
|
self.tabview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KMainW, 216 + 60) style:UITableViewStylePlain];
|
|
self.tabview.backgroundColor = [UIColor whiteColor];
|
|
self.tabview.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
self.tabview.delegate = self;
|
|
self.tabview.scrollEnabled = NO;
|
|
self.tabview.dataSource = self;
|
|
|
|
UIButton *cancleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[cancleBtn setTitle:@"取消" forState:UIControlStateNormal];
|
|
[cancleBtn setTitleColor:GIGARGB(165,165, 165, 1) forState:UIControlStateNormal];
|
|
[cancleBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
cancleBtn.frame = CGRectMake(0,1, KMainW,60);
|
|
|
|
self.tabview.tableFooterView = cancleBtn;
|
|
[holdview addSubview:self.tabview];
|
|
|
|
|
|
|
|
}
|
|
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
|
|
return 3;
|
|
}
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
MaskActionSheetViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MaskActionSheetViewCell"];
|
|
if (!cell) {
|
|
cell = [[[NSBundle mainBundle] loadNibNamed:@"MaskActionSheetViewCell" owner:self options:nil] lastObject];
|
|
}
|
|
[cell comfirmTitles:indexPath];
|
|
return cell;
|
|
}
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
return 54;
|
|
}
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
if (self.action) {
|
|
self.action(indexPath.row);
|
|
[self cancleDissmiss];
|
|
}
|
|
}
|
|
|
|
-(void)show:(actionSheetAction)action{
|
|
|
|
self.action = action;
|
|
|
|
}
|
|
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
|
if ([touches anyObject].view != self.tabview) {
|
|
[self cancleDissmiss];
|
|
}
|
|
|
|
}
|
|
|
|
-(void)cancelAction{
|
|
[self cancleDissmiss];
|
|
}
|
|
|
|
-(void)cancleDissmiss{
|
|
[UIView animateWithDuration:1.0 animations:^{
|
|
self.tabview.frame = CGRectMake(0, KMainH - 216, KMainW, 0);
|
|
}];
|
|
[self removeFromSuperview];
|
|
}
|
|
|
|
|
|
@end
|