注:本框架为多数项目开发基类通用框架结构,如有特殊需求可进行单独定制
- 框架目录结构如下:
框架在使用的过程中还是发现了一些问题的,开始的时候是使用的MVC目录结构,后续项目维护由于项目庞大的业务逻辑改为MVVM,下面说一下两者的优缺点吧
MVVM
优点:业务逻辑清晰,可重复使用view,代码高度解耦
缺点:过于分离的层次造成项目维护代码较高,代码量也相对增加,后期修复bug时成本也较高,不易维护
- MVC
优点:代码逻辑清晰,较为容易理解,层次较为分明
缺点:由于庞大的业务逻辑都会堆放在Controller造成控制器过于臃肿,view以及一些其他类也较为难
以实现循环利用,难以分离
基类框架的设计初衷
响应式编程和函数式编程思想
这里说明一下,如果有同学不理解什么是响应式编程和函数式编程的话,请点击下面的链接//www.greatytc.com/p/7017a220f34c
提前看下接口吧
接口
//1.1.2 标题文本、颜色、字体
- (void)naviTitle:(NSString *)title color:(UIColor *)color font:(UIFont *)font;
- (HRBaseViewController *(^)(NSString *title))setupNaviTitle;
- (HRBaseViewController *(^)(UIColor *))setupTitleColor;
- (HRBaseViewController *(^)(UIFont *))setupTitleFont;
//1.2.1 左按钮标题
- (void)leftItemTitle:(NSString *)title color:(UIColor *)color font:(UIFont *)font action:(void(^)())action;
- (HRBaseViewController *(^)(NSString *title, UIColor *color, UIFont *font, void(^action)()))setupLeftTitleItem;
//1.2.2 左按钮图片
- (void)leftImageItem:(NSString *)imageName action:(void(^)())action;
- (HRBaseViewController *(^)(NSString *imageName, void(^action)()))setupLeftImageItem;
//1.2.3 左按钮通用
- (void)leftItems:(NSArray <HRBarItem *>*)items actions:(void(^)(NSInteger index))actions;
- (HRBaseViewController *(^)(NSArray <HRBarItem *>*items,void (^actions)(NSInteger index)))setupLeftItems;
//1.3.1 右按钮标题
- (void)rightItemTitle:(NSString *)title color:(UIColor *)color font:(UIFont *)font action:(void(^)())action;
- (HRBaseViewController *(^)(NSString *title, UIColor *color, UIFont *font, void(^action)()))setupRightTitleItem;
//1.3.2 右按钮图片
- (void)rightImageItem:(NSString *)imageName action:(void(^)())action;
- (HRBaseViewController *(^)(NSString *imageName, void(^action)()))setupRightImageItem;
//1.3.3 右按钮通用
- (void)rightItems:(NSArray <HRBarItem *>*)items actions:(void(^)(NSInteger index))actions;
- (HRBaseViewController *(^)(NSArray <HRBarItem *>*items,void (^actions)(NSInteger index)))setupRightItems;
//1.4.1 系统返回按钮隐藏
@property (assign, nonatomic) BOOL hiddenBackItem;
//- (HRBaseViewController *(^)())setupHiddenBackItem;
具体使用以及设计思路会在下个章节进行说明,敬请期待...
有任何问题可以随时进行咨询,欢迎...
邮件:750460196@qq.com