iOS框架設(shè)計(jì)煎楣,讓iOS app開發(fā)快速開始LYLKit【OC版本】

[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ǔ)類的功能
  1. NullSafe null 的安全處理
  2. NineBigSort 排序算法展示骡尽,沒(méi)有實(shí)際意義
  3. NSString+tools.h 字符的數(shù)據(jù)處理
  4. UIImage+tools.h 圖片的處理工具
  5. UIColor+tools.h 顏色的處理工具
  6. UIView+tools.h 視圖的處理
Other:
  1. MyAnimation動(dòng)畫處理
  2. LocationManager 定位組件
  3. AppControl 全局組件

Base 文件 【基礎(chǔ)類(繼承后直接使用遣妥,擴(kuò)展了原有類的功能)】

  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];// 設(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(@"完成");
        }
    }];
}
掉落動(dòng)畫

基本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"];

}
BaseViewController+RTRootNavigationController

BaseTableViewController子類

BaseCollectionViewController子類

[還在完善當(dāng)中。套媚。缚态。]

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市堤瘤,隨后出現(xiàn)的幾起案子玫芦,更是在濱河造成了極大的恐慌,老刑警劉巖本辐,帶你破解...
    沈念sama閱讀 217,277評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件桥帆,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡慎皱,警方通過(guò)查閱死者的電腦和手機(jī)环葵,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,689評(píng)論 3 393
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)宝冕,“玉大人张遭,你說(shuō)我怎么就攤上這事〉乩妫” “怎么了菊卷?”我有些...
    開封第一講書人閱讀 163,624評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)宝剖。 經(jīng)常有香客問(wèn)我洁闰,道長(zhǎng),這世上最難降的妖魔是什么万细? 我笑而不...
    開封第一講書人閱讀 58,356評(píng)論 1 293
  • 正文 為了忘掉前任扑眉,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘腰素。我一直安慰自己聘裁,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,402評(píng)論 6 392
  • 文/花漫 我一把揭開白布弓千。 她就那樣靜靜地躺著衡便,像睡著了一般。 火紅的嫁衣襯著肌膚如雪洋访。 梳的紋絲不亂的頭發(fā)上镣陕,一...
    開封第一講書人閱讀 51,292評(píng)論 1 301
  • 那天,我揣著相機(jī)與錄音姻政,去河邊找鬼呆抑。 笑死,一個(gè)胖子當(dāng)著我的面吹牛汁展,可吹牛的內(nèi)容都是我干的理肺。 我是一名探鬼主播,決...
    沈念sama閱讀 40,135評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼善镰,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼妹萨!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起炫欺,我...
    開封第一講書人閱讀 38,992評(píng)論 0 275
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤乎完,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后品洛,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體树姨,經(jīng)...
    沈念sama閱讀 45,429評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,636評(píng)論 3 334
  • 正文 我和宋清朗相戀三年桥状,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了帽揪。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,785評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡辅斟,死狀恐怖转晰,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情士飒,我是刑警寧澤查邢,帶...
    沈念sama閱讀 35,492評(píng)論 5 345
  • 正文 年R本政府宣布,位于F島的核電站酵幕,受9級(jí)特大地震影響扰藕,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜芳撒,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,092評(píng)論 3 328
  • 文/蒙蒙 一邓深、第九天 我趴在偏房一處隱蔽的房頂上張望未桥。 院中可真熱鬧,春花似錦芥备、人聲如沸冬耿。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,723評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至酷师,卻和暖如春讶凉,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背山孔。 一陣腳步聲響...
    開封第一講書人閱讀 32,858評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工懂讯, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人台颠。 一個(gè)月前我還...
    沈念sama閱讀 47,891評(píng)論 2 370
  • 正文 我出身青樓褐望,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親串前。 傳聞我的和親對(duì)象是個(gè)殘疾皇子瘫里,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,713評(píng)論 2 354