This commit is contained in:
lianxiang
2018-10-12 09:12:54 +08:00
parent dc1b1e330f
commit 97af177b88
37 changed files with 583 additions and 173 deletions
@@ -27,12 +27,12 @@
-(void)sendLocalNotification:(NSString *)alertBoday fireTimeInterval:(NSTimeInterval )timeInterval alertAction:(NSString *)alertAction withIdentifier:(NSString *)identifier;
/**
删除当前程序注册的所有通知 ios 8 后 iOS10 前
删除当前程序注册的所有通知
*/
-(void)cancelAllLocalNoitification;
/**
删除指定的通知,一般用于取消重复的通知或者还没有被调用的通知,先获取通知,再遍历根据条件去删除(条件是 UserInfo 的值,是发送通知时所携带的参数) ios 8 后 iOS10 前
删除指定的通知,一般用于取消重复的通知或者还没有被调用的通知,先获取通知,再遍历根据条件去删除(条件是 UserInfo 的值,是发送通知时所携带的参数)
*/
-(void)cancelLocalNitificationByUserInfowithIdentifier:(NSString *)identifier;
@@ -41,7 +41,6 @@
*/
-(void)didResaveloaclNitification:(UILocalNotification *)localNitification;
//处理通知。。
@@ -74,7 +74,7 @@
if (@available(iOS 10.0, *)) {
[[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications];
[[UNUserNotificationCenter currentNotificationCenter] removeAllPendingNotificationRequests];
} else {
// Fallback on earlier versions
@@ -87,7 +87,7 @@
-(void)cancelLocalNitificationByUserInfowithIdentifier:(NSString *)identifier{
if (@available(iOS 10.0, *)) {
[[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers:@[identifier]];
[[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers:@[identifier]];
} else {
// Fallback on earlier versions
NSArray *notifiArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
+2
View File
@@ -149,7 +149,9 @@ NSString *const kShowUserTested = @"kShowUserTested";
time = 15 * 60;
//time = MASKTIME_DEFAULT;
}
time = 5;
return time;
}
+(void)saveUserTestFlag:(BOOL)tested{
BIN
View File
Binary file not shown.
@@ -0,0 +1,23 @@
//
// LXCustomActionSheet.h
// CustomUISwitch
//
// Created by lianxiang on 2018/10/11.
// Copyright © 2018年 lian. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface LXCustomActionSheet : UIView
- (instancetype)initWithTitle:(NSString*)title
optionsArr:(NSArray*)optionsArr
cancelTitle:(NSString*)cancelTitle
selectedBlock:(void(^)(NSInteger))selectedBlock
cancelBlock:(void(^)(void))cancelBlock;
-(void)show;
@end
@@ -0,0 +1,192 @@
//
// LXCustomActionSheet.m
// CustomUISwitch
//
// Created by lianxiang on 2018/10/11.
// Copyright © 2018年 lian. All rights reserved.
//
#import "LXCustomActionSheet.h"
#define Screen_Width [UIScreen mainScreen].bounds.size.width
#define Screen_height [UIScreen mainScreen].bounds.size.height
#define SPACE 10
@interface LXCustomActionSheet ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UIView *maskView;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *optionsArr;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *cancelTitle;
@property (nonatomic, strong) UIView *headView;
@property (nonatomic, copy) void(^selectedBlock)(NSInteger);
@property (nonatomic, copy) void(^cancelBlock)(void);
@end
@implementation LXCustomActionSheet
- (instancetype)initWithTitle:(NSString*)title
optionsArr:(NSArray*)optionsArr
cancelTitle:(NSString*)cancelTitle
selectedBlock:(void(^)(NSInteger))selectedBlock
cancelBlock:(void(^)(void))cancelBlock{
if (self = [super init]) {
_title = title;
_optionsArr = optionsArr;
_cancelTitle = cancelTitle;
_selectedBlock = selectedBlock;
_cancelBlock = cancelBlock;
[self craetUI];
}
return self;
}
- (void)craetUI {
self.frame = [UIScreen mainScreen].bounds;
[self addSubview:self.maskView];
[self addSubview:self.tableView];
}
- (UIView*)maskView {
if (!_maskView) {
_maskView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
_maskView.backgroundColor = [UIColor blackColor];
_maskView.alpha = .5;
_maskView.userInteractionEnabled = YES;
}
return _maskView;
}
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.rowHeight = 44.0;
_tableView.bounces = NO;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.backgroundColor = [UIColor clearColor];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
UIView *tabHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0,Screen_Width, 50)];
tabHeader.backgroundColor = [UIColor whiteColor];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:
CGRectMake(0, 0, Screen_Width, 50) byRoundingCorners:
UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:
CGSizeMake(10, 10)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
maskLayer.frame = tabHeader.bounds;
maskLayer.path = maskPath.CGPath;
tabHeader.layer.mask = maskLayer;
UILabel *titleLabe = [[UILabel alloc] init];
titleLabe.frame = tabHeader.bounds;
titleLabe.textAlignment = NSTextAlignmentCenter;
titleLabe.text = self.title;
titleLabe.font = GIGA_TEXTFONTMEDIUM(12);
titleLabe.textColor = GIGA_MAIN_BGCOLOR;
[tabHeader addSubview:titleLabe];
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, tabHeader.frame.size.height -0.5, Screen_Width, 0.5)];
lineView.backgroundColor = [UIColor colorWithRed:222/255.0f green:222/255.0f blue:222/255.0f alpha:1];
[tabHeader addSubview:lineView];
self.headView = tabHeader;
_tableView.tableHeaderView = self.headView;
// _tableView.separatorInset = UIEdgeInsetsMake(0, -50, 0, 0);
[_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Navi_Cell"];
}
return _tableView;
}
#pragma mark TableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return (section == 0)?_optionsArr.count:1;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Navi_Cell"];
cell.textLabel.font = GIGA_TEXTFONTMEDIUM(15);
cell.textLabel.textColor = GIGA_MAIN_BGCOLOR;
if (indexPath.section == 0) {
cell.textLabel.text = _optionsArr[indexPath.row];
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0,cell.frame.size.height - 0.5, Screen_Width, 0.5)];
lineView.backgroundColor = [UIColor colorWithRed:222/255.0f green:222/255.0f blue:222/255.0f alpha:1];
[cell.contentView addSubview:lineView];
} else {
cell.textLabel.text = _cancelTitle;
}
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
if (self.selectedBlock) {
self.selectedBlock(indexPath.row);
}
}else{
if (self.cancelBlock) {
self.cancelBlock();
}
}
[self dismiss];
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
if (section==0) {
return 3;
}
return 0;
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UIView *footerView = [[UIView alloc] init];
footerView.backgroundColor = [UIColor colorWithRed:222/255.0f green:222/255.0f blue:222/255.0f alpha:1];
return footerView;
}
-(void)show{
[[UIApplication sharedApplication].keyWindow addSubview:self];
}
- (void)layoutSubviews {
[super layoutSubviews];
[self showTab];
}
- (void)showTab{
_tableView.frame = CGRectMake(0,Screen_height, Screen_Width, _tableView.rowHeight * (_optionsArr.count + 1) + 50 + 3);
[UIView animateWithDuration:.5 animations:^{
CGRect rect = self->_tableView.frame;
rect.origin.y -= self->_tableView.bounds.size.height;
self->_tableView.frame = rect;
}];
}
- (void)dismiss {
[UIView animateWithDuration:.5 animations:^{
CGRect rect = self->_tableView.frame;
rect.origin.y += self->_tableView.bounds.size.height;
self->_tableView.frame = rect;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
if (self.cancelBlock) {
self.cancelBlock();
}
[self dismiss];
}
@end