Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
//
// LXActionView.h
// ISCTest
//
// Created by imac on 16/5/18.
// Copyright © 2016年 xiang. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol LXActionSheetDelegate
@end
@interface LXActionView : UITableView
@property(nonatomic,assign) NSInteger selectedIndex;
@property(nonatomic,copy) void(^didSelectedAtIndexPath)(NSString *title,NSIndexPath *indexPath);
@property (nonatomic, strong) NSString *selectedTitle;
- (void)setImageNameList:(NSArray *)imageNameList titles:(NSArray *)titles;
- (void)setOnlytitles:(NSArray *)titles;
- (void)showActionSheet;
- (void)actionSheetViewHidden;
@end
+225
View File
@@ -0,0 +1,225 @@
//
// LXActionView.m
// ISCTest
//
// Created by imac on 16/5/18.
// Copyright © 2016年 xiang. All rights reserved.
//
#import "LXActionView.h"
#import "LXColorTools.h"
#define FontColorGray @"#666666"
#define TableViewSeparatorRGBColor [UIColor colorWithRed:0.78 green:0.78 blue:0.8 alpha:1]
//#define LXImageWithImageName(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"LXIMGResource.bundle/images/%@",imageName]]
@interface LXActionView ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) NSArray *titles;
@property (nonatomic, strong) NSArray *imageNames;
@property (nonatomic, strong) UIView *bgView;
@end
@implementation LXActionView
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
{
self = [super initWithFrame:frame style:style];
if (self) {
self.delegate = self;
self.dataSource = self;
self.backgroundColor = [UIColor clearColor];
self.layer.cornerRadius = 4;
self.separatorColor = [UIColor clearColor];
self.scrollEnabled = NO;
self.scrollsToTop = NO;
UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIApplication sharedApplication].keyWindow.frame.size.width, [UIApplication sharedApplication].keyWindow.frame.size.height)];
bgView.backgroundColor = [UIColor blackColor];
bgView.alpha = 0.2;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(actionSheetViewHidden)];
[bgView addGestureRecognizer:tap];
self.bgView = bgView;
}
return self;
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.titles.count + 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.contentView.layer.cornerRadius = 4;
cell.layer.cornerRadius = 4;
cell.backgroundColor = [UIColor whiteColor];
cell.contentView.backgroundColor = [UIColor whiteColor];
if (indexPath.row == self.titles.count + 1){
cell.textLabel.text = @"取消";
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.textLabel.font = [UIFont systemFontOfSize:17];
cell.textLabel.textColor = [LXColorTools colorWithHexString:FontColorGray];
}else if (indexPath.row == self.titles.count){
cell.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
if (indexPath.row == 1) {
cell.contentView.backgroundColor = TableViewSeparatorRGBColor;
}
}else {
NSString *title = nil;
//NSString *imageName = nil;
//if (self.titles.count > 0 && self.imageNames > 0) {
// if (indexPath.row < self.titles.count) {
// title = [self.titles objectAtIndex:indexPath.row];
// imageName = [self.imageNames objectAtIndex:indexPath.row];
// }
//UIView *cellView = [self createCellViewWithTitle:title imageName:imageName];
// [cell.contentView addSubview:cellView];
// }
if (self.titles.count > 0 ) {
if (indexPath.row < self.titles.count) {
title = [self.titles objectAtIndex:indexPath.row];
}
UIView *cellView = [self createCellViewWithTitle:title];
[cell.contentView addSubview:cellView];
}
}
return cell;
}
- (UIView *)createCellViewWithTitle:(NSString *)title imageName:(NSString *)imageName
{
UIView *cellContentView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, 38)];
UIView *cellView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 80, 38)];
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
imageView.image = LXImageWithImageName(imageName);
[cellView addSubview:imageView];
cellView.backgroundColor = [UIColor clearColor];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(40, 0, 40, 38)];
label.font = [UIFont systemFontOfSize:17];
label.textColor = [LXColorTools colorWithHexString:FontColorGray];
label.backgroundColor = [UIColor clearColor];
[cellView addSubview:label];
label.text = title;
UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 38, self.frame.size.width, 2)];
lineView.backgroundColor = TableViewSeparatorRGBColor;
[cellContentView addSubview:cellView];
cellView.center = CGPointMake(cellContentView.frame.size.width/2, 20);
[cellContentView addSubview:lineView];
cellContentView.center = CGPointMake(self.frame.size.width/2, 20);
return cellContentView;
}
- (UIView *)createCellViewWithTitle:(NSString *)title
{
UIView *cellContentView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, 60)];
UIView *cellView = [[UIView alloc]initWithFrame:CGRectMake(0,0,self.frame.size.width, 60)];
cellView.backgroundColor = [UIColor clearColor];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0,0,self.frame.size.width, 60)];
label.font = [UIFont systemFontOfSize:17];
label.textColor = [LXColorTools colorWithHexString:FontColorGray];
label.backgroundColor = [UIColor clearColor];
label.textAlignment = NSTextAlignmentCenter;
[cellView addSubview:label];
label.text = title;
UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0,59, self.frame.size.width, 1)];
lineView.backgroundColor = TableViewSeparatorRGBColor;
[cellContentView addSubview:lineView];
[cellContentView addSubview:cellView];
cellView.center = CGPointMake(cellContentView.frame.size.width/2,30);
cellContentView.center = CGPointMake(self.frame.size.width/2, 30);
return cellContentView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == self.titles.count) {
return 10;
}
return 60;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self actionSheetViewHidden];
if (indexPath.row < self.titles.count) {
self.selectedTitle = self.titles[indexPath.row];
if (self.didSelectedAtIndexPath) {
self.didSelectedAtIndexPath(self.selectedTitle,indexPath);
}
}
self.selectedIndex = indexPath.row;
}
- (void)setImageNameList:(NSArray *)imageNameList titles:(NSArray *)titles
{
self.titles = titles;
self.imageNames = imageNameList;
[self reloadData];
}
- (void)setOnlytitles:(NSArray *)titles{
self.titles = titles;
[self reloadData];
}
- (void)showActionSheet
{
CGFloat heigth = self.contentSize.height;
[self removeFromSuperview];
[self.bgView removeFromSuperview];
UIWindow *window = [UIApplication sharedApplication].keyWindow;
self.bgView.hidden = NO;
[UIView animateWithDuration:0.2 animations:^{
self.frame = CGRectMake(self.frame.origin.x, window.frame.size.height-heigth, self.frame.size.width,heigth);
} completion:^(BOOL finished) {
[window addSubview:self.bgView];
[window addSubview:self];
}];
}
- (void)actionSheetViewHidden
{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
[UIView animateWithDuration:0.2 animations:^{
self.bgView.hidden = YES;
self.frame = CGRectMake(self.frame.origin.x, window.frame.size.height, self.frame.size.width, self.frame.size.height);
} completion:^(BOOL finished) {
[self removeFromSuperview];
[self.bgView removeFromSuperview];
}];
}
@end
+16
View File
@@ -0,0 +1,16 @@
//
// LXColorTools.h
// ISCTest
//
// Created by imac on 16/5/18.
// Copyright © 2016年 xiang. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface LXColorTools : NSObject
//convert hex to RGB
+ ( UIColor *)colorWithHexString:(NSString *)stringToConvert;
@end
+47
View File
@@ -0,0 +1,47 @@
//
// LXColorTools.m
// ISCTest
//
// Created by imac on 16/5/18.
// Copyright © 2016年 xiang. All rights reserved.
//
#import "LXColorTools.h"
#define DEFAULT_VOID_COLOR [UIColor whiteColor]
@implementation LXColorTools
+ ( UIColor *)colorWithHexString:(NSString *)stringToConvert
{
NSString *cString = [[stringToConvert stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
if ([cString length] < 6)
return DEFAULT_VOID_COLOR;
if ([cString hasPrefix:@"#"])
cString = [cString substringFromIndex:1];
if ([cString length] != 6)
return DEFAULT_VOID_COLOR;
NSRange range;
range.location = 0;
range.length = 2;
NSString *rString = [cString substringWithRange:range];
range.location = 2;
NSString *gString = [cString substringWithRange:range];
range.location = 4;
NSString *bString = [cString substringWithRange:range];
unsigned int r, g, b;
[[NSScanner scannerWithString:rString] scanHexInt:&r];
[[NSScanner scannerWithString:gString] scanHexInt:&g];
[[NSScanner scannerWithString:bString] scanHexInt:&b];
return [UIColor colorWithRed:((float) r / 255.0f)
green:((float) g / 255.0f)
blue:((float) b / 255.0f)
alpha:1.0f];
}
@end