[toc]
LYLKit
git地址:https://gitee.com/eillyer/lylkit
介绍
通过多年的iOS开发经验,封装一款集合各个第三方控件和自己封装的控件。让每个新建app,不用去考虑过多的小细节。主要是以MVC模式设计的OC语言库。希望在慢慢的维护中,使这个库能够很健壮。
使用指南
1. 需要pod导入第三方库
pod 'BRPickerView' #选择器
pod 'LYEmptyView' #列表空页面占位
pod 'AFNetworking' #网络框架
pod 'SDWebImage' #图片框架
pod 'MBProgressHUD' #弹出框
pod 'JPush' #推送
pod 'MJRefresh' #刷新
pod 'Masonry' #手动布局
pod 'MJExtension' #json——>model
pod 'IQKeyboardManager' #智能键盘
pod 'IFMMenu' #仿微信添加好友下拉组件
pod 'TABAnimated' #预加载动画
2. 所有文件都在 AllSources
文件中,使用时直接将这个文件拖入项目中直接使用
3. 配置info.plist文件,设置pch文件路径
4. 开始使用
文件功能介绍
HeaderSource
文件夹 【头文件】
SafeScreen.h
屏幕适配
SDKKeySet.h
第三方组件初始化配置设置参数
AppUseToolsHeader
工具类别设置
UIMainSet.h
本地app的死值设置
NetMainUrlHeader
网络主服务器地址(有测试、开发、生产的切换)
NetWork 文件
【网络工具类】
NetWork.h
网络接口调用,直接使用NSMutableDictionary *dict = @{}.mutableCopy; //入参 dict[@"name"] = user; dict[@"PWD"] = pwd; // 接口地址 NSString *url = [NSString stringWithFormat:@"%@%@",BaseURL,API_test_URL]; //发起请求,vc表示当前控制器,传入vc表示请求过程中,屏幕展示小菊花,不传入则不展示小菊花 [NetWork getNetWorkOfURL:url parameters:dict selfVC:vc success:^(NSDictionary *successDict) { //成功回调 } failure:^(NSDictionary *failureDict) { //失败回调 }];
NetWorkTo.h
网络接口调用,封装使用//对NetWork根据不同接口进行再次业务封装,不暴露接口与入参,对数据进行再处理,这种方式是要根据业务去处理的, + (void)toLoginUserVC:(nullable UIViewController *)vc user:(NSString *_Nonnull)user pwd:(NSString *_Nullable)pwd Success:(void(^_Nullable)(NSDictionary * _Nullable dict))successBlock error:(void(^_Nullable)(NSString * _Nullable error))errorBlock{ NSMutableDictionary *dict = @{}.mutableCopy; dict[@"name"] = user; dict[@"PWD"] = pwd; NSString *url = [NSString stringWithFormat:@"%@%@",BaseURL,API_test_URL]; [NetWork getNetWorkOfURL:url parameters:dict selfVC:vc success:^(NSDictionary *successDict) { successBlock(successDict); } failure:^(NSDictionary *failureDict) { errorBlock(@"请求失败原因"); }]; }
ServerAPIPath
接口地址
AFNetWorkingHelper.h
AF的封装
Tools 文件
【工具类】
Category:分类,主要扩展了基础类的功能
NullSafe
null 的安全处理NineBigSort
排序算法展示,没有实际意义NSString+tools.h
字符的数据处理UIImage+tools.h
图片的处理工具UIColor+tools.h
颜色的处理工具UIView+tools.h
视图的处理Other:
MyAnimation
动画处理LocationManager
定位组件AppControl
全局组件
Base 文件
【基础类(继承后直接使用,扩展了原有类的功能)】
BaseViewController
BaseTableViewController
BaseModel
BaseView
BaseNavigationController
- 等...
功能效果展示
颜色渐变 + 切圆边 + 描边 + 阴影(忽略mask)
//代码添加
UIView * view = [[UIView alloc] initWithFrame:CGRectMake(30, 130, 100, 100)];
view.backgroundColor = kGrayColor;
[self.view addSubview:view];
[view setJianBianStarColor:kBlueColor endColor:kRedColor isHorizontally:YES];// 设置渐变色
[view setR:50 wid:5 color:kBlackColor RoundingCorners:(UIRectCornerTopLeft|UIRectCornerBottomRight) DottedLine:YES];//切圆弧,设置描边
[view setYinyingColor:kBlackColor alpha:1 offsetX:10 Y:40 radius:10];//设置阴影,代码添加必须在有父试图的前提下
// xib 添加
[self.image setR:50 wid:5 color:kBlackColor RoundingCorners:(UIRectCornerTopLeft|UIRectCornerBottomRight) DottedLine:YES];//切圆弧,设置描边
[self.image setYinyingColor:kBlackColor alpha:1 offsetX:10 Y:40 radius:10];//设置阴影
颜色渐变 + 切圆边 + 描边 + 阴影
定位,权限没有开通时,alert提示
【#import "LocationManager.h"
】
//实例化
LocationManager *location = [LocationManager sharedLocatiomManager];
//回调
location.sendValueBlock = ^(NSString *lng, NSString *lat, CLPlacemark *weizhi, BOOL isOK, NSString *error) {
NSLog(@"经度:%@ 纬度:%@ 定位城市:%@ 是否定位成功:%@ 异常信息:%@",lng,lat,weizhi.locality,isOK?@"成功":@"失败",error);
};
//启动定位
[location findMe];
动画
【#import "MyAnimation.h"
】
- (void)btnAction:(UIButton *)sender{
[[MyAnimation shareMyAnimation] animationWithDiaoLuo:@[self.red,sender] inView:self.view finishBlock:^(BOOL finish) {
if (finish) {
NSLog(@"完成");
}
}];
}
掉落动画
基本vc
BaseViewController.h
子类
push代码:
- (void)viewDidLoad { [super viewDidLoad]; //push按钮 UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(100,100, 100,100)]; [btn addTarget:self action:@selector(btnAction) forControlEvents:UIControlEventTouchUpInside]; [btn setTitle:@"按钮" forState:UIControlStateNormal]; [btn setBackgroundColor:[UIColor redColor]]; [self.view addSubview:btn]; //导航标题 kNaviTitle(@"NAVIbASE"); // 设置返回按钮 [self setupNavigationItemWithImg:nil title:@"导航按钮" isItemType:backNaviItem]; } //push后,导航控制器移除栈中的当前控制器 - (void)btnAction{ NAVIbASE *vc= [NAVIbASE new]; BaseNavigationController *navi = [[BaseNavigationController alloc] initWithRootViewController:vc]; [self presentViewController:navi animated:YES completion:^{ //移除当前控制器,push 和 present 都可以 [self.rt_navigationController removeViewController:self]; }]; }
BaseTableViewController
子类
完整代码:
- (void)viewDidLoad { [super viewDidLoad]; [self settingData]; [self settingView]; } - (void)settingData{ [self netWorking]; } - (void)settingView{ self.count = 0; [self settingTable]; //预加载动画 [self setTableViewSkeletonWithCell:[BBB3TableViewCell class] column:10]; //展示默认无数据占位 [self showDefaultEmpty]; //设置导航栏右侧按钮 [self setupNavigationItemWithImg:nil title:@"+5" isItemType:rightNaviItem]; } //右侧按钮点击事件,是通过BaseViewController继承来的 - (void)navRightClick{ self.count = 5; } - (void)settingTable{ UINib *nib1 = [UINib nibWithNibName:@"BBB3TableViewCell" bundle:[NSBundle mainBundle]]; [self.tableView registerNib:nib1 forCellReuseIdentifier:@"BBB3TableViewCell"]; self.tableView.estimatedRowHeight = UITableViewAutomaticDimension; } //是通过BaseTableViewController继承来的,下拉刷新和上拉加载 - (void)loadListData{ __weak typeof (self) weakSelf = self; dispatch_time_t delayTime1 = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)); dispatch_after(delayTime1, dispatch_get_main_queue(), ^{ [weakSelf resetData];//返回数据后列表数据刷新 [weakSelf.tableView tab_endAnimation];//停止预加载 [weakSelf endRefreshing];//停止刷新 [weakSelf.tableView reloadData]; }); } //网络请求 - (void)netWorking{ } #pragma mark - tableView delegate - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 80; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ BBB3TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BBB3TableViewCell"]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ }
主要代码完成:展位图+动画预加载+上拉下拉
,过程中不需要考虑
分页数据的page+1
,
//预加载动画
[self setTableViewSkeletonWithCell:[BBB3TableViewCell class] column:10];
//展示默认无数据占位
[self showDefaultEmpty];
//设置导航栏右侧按钮
[self setupNavigationItemWithImg:nil title:@"+5" isItemType:rightNaviItem];
BaseCollectionViewController
子类
主要代码完成:展位图+动画预加载+上拉下拉
,过程中不需要考虑
分页数据的page+1
,
{
//预加载动画
[self setCollectionViewSkeletonWithCell:[CCCCollectionViewItem class] column:10 itemSize:CGSizeMake(kScreenWidth/2, kScreenHeight/4)];
//展示默认无数据占位
[self showDefaultEmpty];
//设置导航栏右侧按钮
[self setupNavigationItemWithImg:nil title:@"+5" isItemType:rightNaviItem];
}
- (void)settingTable{
//设置布局方式
BaseFlowLayout *flowLayout = [[BaseFlowLayout alloc] initWithCount:2 width:kScreenWidth height:kScreenHeight/4 isH:NO];
[self.collectionView setCollectionViewLayout:flowLayout];
UINib *nib1 = [UINib nibWithNibName:@"CCCCollectionViewItem" bundle:[NSBundle mainBundle]];
[self.collectionView registerNib:nib1 forCellWithReuseIdentifier:@"CCCCollectionViewItem"];
}
BaseViewController+RTRootNavigationController
BaseTableViewController子类
BaseCollectionViewController子类
[还在完善当中。。。]