ios辅助UI

2018-04-30  本文已影响77人  师傅我坚持不住了

WKCBaseUI

Some base on BaseUI

pod 'WKCBaseUI'

TableView

#import <WKCBaseUI/WKCBaseTableView.h>
  1. 自适应cell(row,其他同理)
    (1) 设置可以自适应.
_tableView.isAutoRowHeight = YES;

(2)在代理方法 tableView:willDisplayCell:forRowAtIndexPath: 和 tableView:estimatedHeightForRowAtIndexPath:中分别缓存和读取高度.

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
return [self.tableView readRowHeightAtIndexPath:indexPath];
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
[self.tableView saveRowHeightWithCell:cell atIndexPath:indexPath];
}
  1. 设置分割线位置.在tableView代理tableView:willDisplayCell:forRowAtIndexPath:方法中均设置


    分割线.png
  2. 刷新(以下拉为例)
    (1)普通类型:有箭头、有时间、有下拉状态提示.
__weak typeof(self)weakSelf = self;
[_tableView setUpBaseHeaderRefresh:^{
[weakSelf.tableView.mj_header endRefreshing];
}];

(2)只有菊花,可以设置菊花类型.(Gray,white以及largeWhite)

__weak typeof(self)weakSelf = self;
[_tableView setUpIndicatorHeaderRefreshWithIndicatorStyle:UIActivityIndicatorViewStyleGray completionHandle:^{
[weakSelf.tableView.mj_header endRefreshing];
}];

(3)自定义图片的(可是动图)

__weak typeof(self)weakSelf = self;
[_tableView setUpImageHeaderRefreshWithImages:@[[UIImage imageNamed:@"rectangle15Copy5"]] completionHandle:^{
[weakSelf.tableView.mj_header endRefreshing];
}];
  1. 修补背景(可直接添加背景色或是图片)
[self.tableView setUpScrollViewWithColor:[UIColor blueColor]];
修补背景.gif

CollectionView

#import <WKCBaseUI/WKCBaseCollectionView.h>

TarBarController(下方适用于纯代码)

#import <WKCBaseUI/WKCBaseTabBarController.h>
  1. 创建控制器模型.
- (WKCBaseViewControllerModel *)main {
            if (!_main) {
                    WKCMainViewController *controller = [WKCMainViewController new];
                    NSString *title = @"主页";
                    UIImage *normalImage = [UIImage imageNamed:@"Tab_Mine_Normal"];
                    UIImage * selectedImage = [UIImage imageNamed:@"Tab_Main_Selected"];
                    NSDictionary *attributedNoramlTitle = @{NSForegroundColorAttributeName: [UIColor blackColor],NSFontAttributeName: [UIFont systemFontOfSize:15]};
NSDictionary *attributedSelectedTitle = @{NSForegroundColorAttributeName: [UIColor blueColor],NSFontAttributeName: [UIFont boldSystemFontOfSize:17]};
                 _main = [[WKCBaseViewControllerModel alloc] initWithDictionary:@{@"controller":controller,@"title":title,@"normalImage":normalImage,@"selectedImage":selectedImage,@"attributedNoramlTitle":attributedNoramlTitle,@"attributedSelectedTitle":attributedSelectedTitle}];
}
      return _main;
}
  1. 快速加载
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor clearColor];
WKCBaseTabBarController *tabBarController =  [WKCBaseTabBarController new];
tabBarController.bgColor = [UIColor yellowColor];
tabBarController.navigationBgColor = [UIColor redColor];
tabBarController.navigationType = navigationbackTypeWhite;
[tabBarController setUpChildsWithModel:self.main,self.classroom,self.community,self.shopping,self.mine, nil];
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
  1. 这里设置的属性是针对所有控制器的.如需某个控制器特殊,在其内单独更改即可.
  2. 默认push时隐藏底部bar,如不想隐藏,相应控制器内调用系统方法hidesBottomBarWhenPushed即可.
- (BOOL)hidesBottomBarWhenPushed {
           return NO;
}
  1. 适用于凸图,不用额外添加任何操作.会自动根据添加图片的尺寸,自适应位置.


    凸图.png

NavigationViewController

#import <WKCBaseUI/WKCBaseNavigationViewController.h>
@property (nonatomic, strong) UIColor * bgColor;
@property (nonatomic, strong) NSDictionary <NSAttributedStringKey,id>* attributedDictionary;
@property (nonatomic, strong) UIBarButtonItem * leftBarButtonItem;
@property (nonatomic, assign) navigationbackType navigationType;

ViewController

#import <WKCBaseUI/WKCBaseViewController.h>
- (BOOL)shouldNavigationBarHiddien {
    return YES;
}

如果bug或是问题,请私信.github地址.

上一篇下一篇

猜你喜欢

热点阅读