iOS框架设计,让iOS app开发快速开始LYLKit【OC版本】

[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:分类,主要扩展了基础类的功能
  1. NullSafe null 的安全处理
  2. NineBigSort 排序算法展示,没有实际意义
  3. NSString+tools.h 字符的数据处理
  4. UIImage+tools.h 图片的处理工具
  5. UIColor+tools.h 颜色的处理工具
  6. UIView+tools.h 视图的处理
Other:
  1. MyAnimation动画处理
  2. LocationManager 定位组件
  3. AppControl 全局组件

Base 文件 【基础类(继承后直接使用,扩展了原有类的功能)】

  1. BaseViewController
  2. BaseTableViewController
  3. BaseModel
  4. BaseView
  5. BaseNavigationController
  6. 等...

功能效果展示

颜色渐变 + 切圆边 + 描边 + 阴影(忽略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子类

[还在完善当中。。。]

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,753评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,668评论 3 396
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 166,090评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,010评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,054评论 6 395
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,806评论 1 308
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,484评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,380评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,873评论 1 319
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,021评论 3 338
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,158评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,838评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,499评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,044评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,159评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,449评论 3 374
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,136评论 2 356