[toc]
LYLKit
git地址:https://gitee.com/eillyer/lylkit
介紹
通過(guò)多年的iOS開發(fā)經(jīng)驗(yàn),封裝一款集合各個(gè)第三方控件和自己封裝的控件以现。讓每個(gè)新建app狠怨,不用去考慮過(guò)多的小細(xì)節(jié)。主要是以MVC模式設(shè)計(jì)的OC語(yǔ)言庫(kù)邑遏。希望在慢慢的維護(hù)中佣赖,使這個(gè)庫(kù)能夠很健壯。
使用指南
1. 需要pod導(dǎo)入第三方庫(kù)
pod 'BRPickerView' #選擇器
pod 'LYEmptyView' #列表空頁(yè)面占位
pod 'AFNetworking' #網(wǎng)絡(luò)框架
pod 'SDWebImage' #圖片框架
pod 'MBProgressHUD' #彈出框
pod 'JPush' #推送
pod 'MJRefresh' #刷新
pod 'Masonry' #手動(dòng)布局
pod 'MJExtension' #json——>model
pod 'IQKeyboardManager' #智能鍵盤
pod 'IFMMenu' #仿微信添加好友下拉組件
pod 'TABAnimated' #預(yù)加載動(dòng)畫
2. 所有文件都在 AllSources
文件中记盒,使用時(shí)直接將這個(gè)文件拖入項(xiàng)目中直接使用
3. 配置info.plist文件憎蛤,設(shè)置pch文件路徑
4. 開始使用
文件功能介紹
HeaderSource
文件夾 【頭文件】
SafeScreen.h
屏幕適配
SDKKeySet.h
第三方組件初始化配置設(shè)置參數(shù)
AppUseToolsHeader
工具類別設(shè)置
UIMainSet.h
本地app的死值設(shè)置
NetMainUrlHeader
網(wǎng)絡(luò)主服務(wù)器地址(有測(cè)試、開發(fā)纪吮、生產(chǎn)的切換)
NetWork 文件
【網(wǎng)絡(luò)工具類】
NetWork.h
網(wǎng)絡(luò)接口調(diào)用俩檬,直接使用NSMutableDictionary *dict = @{}.mutableCopy; //入?yún)? dict[@"name"] = user; dict[@"PWD"] = pwd; // 接口地址 NSString *url = [NSString stringWithFormat:@"%@%@",BaseURL,API_test_URL]; //發(fā)起請(qǐng)求,vc表示當(dāng)前控制器碾盟,傳入vc表示請(qǐng)求過(guò)程中棚辽,屏幕展示小菊花,不傳入則不展示小菊花 [NetWork getNetWorkOfURL:url parameters:dict selfVC:vc success:^(NSDictionary *successDict) { //成功回調(diào) } failure:^(NSDictionary *failureDict) { //失敗回調(diào) }];
NetWorkTo.h
網(wǎng)絡(luò)接口調(diào)用巷疼,封裝使用//對(duì)NetWork根據(jù)不同接口進(jìn)行再次業(yè)務(wù)封裝晚胡,不暴露接口與入?yún)ⅲ瑢?duì)數(shù)據(jù)進(jìn)行再處理嚼沿,這種方式是要根據(jù)業(yè)務(wù)去處理的估盘, + (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(@"請(qǐng)求失敗原因"); }]; }
ServerAPIPath
接口地址
AFNetWorkingHelper.h
AF的封裝
Tools 文件
【工具類】
Category:分類,主要擴(kuò)展了基礎(chǔ)類的功能
NullSafe
null 的安全處理NineBigSort
排序算法展示骡尽,沒(méi)有實(shí)際意義NSString+tools.h
字符的數(shù)據(jù)處理UIImage+tools.h
圖片的處理工具UIColor+tools.h
顏色的處理工具UIView+tools.h
視圖的處理Other:
MyAnimation
動(dòng)畫處理LocationManager
定位組件AppControl
全局組件
Base 文件
【基礎(chǔ)類(繼承后直接使用遣妥,擴(kuò)展了原有類的功能)】
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];// 設(shè)置漸變色
[view setR:50 wid:5 color:kBlackColor RoundingCorners:(UIRectCornerTopLeft|UIRectCornerBottomRight) DottedLine:YES];//切圓弧,設(shè)置描邊
[view setYinyingColor:kBlackColor alpha:1 offsetX:10 Y:40 radius:10];//設(shè)置陰影攀细,代碼添加必須在有父試圖的前提下
// xib 添加
[self.image setR:50 wid:5 color:kBlackColor RoundingCorners:(UIRectCornerTopLeft|UIRectCornerBottomRight) DottedLine:YES];//切圓弧箫踩,設(shè)置描邊
[self.image setYinyingColor:kBlackColor alpha:1 offsetX:10 Y:40 radius:10];//設(shè)置陰影
定位,權(quán)限沒(méi)有開通時(shí)谭贪,alert提示
【#import "LocationManager.h"
】
//實(shí)例化
LocationManager *location = [LocationManager sharedLocatiomManager];
//回調(diào)
location.sendValueBlock = ^(NSString *lng, NSString *lat, CLPlacemark *weizhi, BOOL isOK, NSString *error) {
NSLog(@"經(jīng)度:%@ 緯度:%@ 定位城市:%@ 是否定位成功:%@ 異常信息:%@",lng,lat,weizhi.locality,isOK?@"成功":@"失敗",error);
};
//啟動(dòng)定位
[location findMe];
動(dòng)畫
【#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]; //導(dǎo)航標(biāo)題 kNaviTitle(@"NAVIbASE"); // 設(shè)置返回按鈕 [self setupNavigationItemWithImg:nil title:@"導(dǎo)航按鈕" isItemType:backNaviItem]; } //push后境钟,導(dǎo)航控制器移除棧中的當(dāng)前控制器 - (void)btnAction{ NAVIbASE *vc= [NAVIbASE new]; BaseNavigationController *navi = [[BaseNavigationController alloc] initWithRootViewController:vc]; [self presentViewController:navi animated:YES completion:^{ //移除當(dāng)前控制器,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]; //預(yù)加載動(dòng)畫 [self setTableViewSkeletonWithCell:[BBB3TableViewCell class] column:10]; //展示默認(rèn)無(wú)數(shù)據(jù)占位 [self showDefaultEmpty]; //設(shè)置導(dǎo)航欄右側(cè)按鈕 [self setupNavigationItemWithImg:nil title:@"+5" isItemType:rightNaviItem]; } //右側(cè)按鈕點(diǎn)擊事件,是通過(guò)BaseViewController繼承來(lái)的 - (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; } //是通過(guò)BaseTableViewController繼承來(lái)的,下拉刷新和上拉加載 - (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];//返回?cái)?shù)據(jù)后列表數(shù)據(jù)刷新 [weakSelf.tableView tab_endAnimation];//停止預(yù)加載 [weakSelf endRefreshing];//停止刷新 [weakSelf.tableView reloadData]; }); } //網(wǎng)絡(luò)請(qǐng)求 - (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{ }
主要代碼完成:展位圖+動(dòng)畫預(yù)加載+上拉下拉
俭识,過(guò)程中不需要考慮
分頁(yè)數(shù)據(jù)的page+1
,
//預(yù)加載動(dòng)畫
[self setTableViewSkeletonWithCell:[BBB3TableViewCell class] column:10];
//展示默認(rèn)無(wú)數(shù)據(jù)占位
[self showDefaultEmpty];
//設(shè)置導(dǎo)航欄右側(cè)按鈕
[self setupNavigationItemWithImg:nil title:@"+5" isItemType:rightNaviItem];
BaseCollectionViewController
子類
主要代碼完成:展位圖+動(dòng)畫預(yù)加載+上拉下拉
慨削,過(guò)程中不需要考慮
分頁(yè)數(shù)據(jù)的page+1
,
{
//預(yù)加載動(dòng)畫
[self setCollectionViewSkeletonWithCell:[CCCCollectionViewItem class] column:10 itemSize:CGSizeMake(kScreenWidth/2, kScreenHeight/4)];
//展示默認(rèn)無(wú)數(shù)據(jù)占位
[self showDefaultEmpty];
//設(shè)置導(dǎo)航欄右側(cè)按鈕
[self setupNavigationItemWithImg:nil title:@"+5" isItemType:rightNaviItem];
}
- (void)settingTable{
//設(shè)置布局方式
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"];
}
[還在完善當(dāng)中。套媚。缚态。]