FTFoldingTableView
FTFoldingTableView。通过简单的代理折叠单元格,并几行代码更改 UI 样式。
屏幕截图
样式 | 左 | 右 |
---|---|---|
折叠 | ![]() |
![]() |
显示 | ![]() |
![]() |
使用方法
必需的方法
- preferred ArrowPosition
- (FTFoldingSectionHeaderArrowPosition)perferedArrowPositionForFTFoldingTableView:(FTFoldingTableView *)ftTableView
{
return self.arrowPosition;
}
- numberOfSectionForFTFoldingTableView
- (NSInteger )numberOfSectionForFTFoldingTableView:(FTFoldingTableView *)ftTableView
{
return 5;
}
- numberOfRowsInSection
- (NSInteger )ftFoldingTableView:(FTFoldingTableView *)ftTableView numberOfRowsInSection:(NSInteger )section
{
return 3;
}
- heightForHeaderInSection
- (CGFloat )ftFoldingTableView:(FTFoldingTableView *)ftTableView heightForHeaderInSection:(NSInteger )section
{
return 60;
}
- heightForRowAtIndexPath
- (CGFloat )ftFoldingTableView:(FTFoldingTableView *)ftTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 50;
}
- titleForHeaderInSection
- (NSString *)ftFoldingTableView:(FTFoldingTableView *)ftTableView titleForHeaderInSection:(NSInteger)section
{
return [NSString stringWithFormat:@"Section %ld",section];
}
- cellForRowAtIndexPath
- (UITableViewCell *)ftFoldingTableView:(FTFoldingTableView *)ftTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [ft_tableView dequeueReusableCellWithIdentifier:DemoTableViewIdentifier forIndexPath:indexPath];
return cell;
}
- didSelectRowAtIndexPath
- (void )ftFoldingTableView:(FTFoldingTableView *)ftTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[ftTableView deselectRowAtIndexPath:indexPath animated:YES];
}
可选方法
- 章节描述ForHeader
- (NSString *)ftFoldingTableView:(FTFoldingTableView *)ftTableView descriptionForHeaderInSection:(NSInteger )section
{
return @"description";
}
- 章节箭头图标ForSection
- (UIImage *)ftFoldingTableView:(FTFoldingTableView *)ftTableView arrowImageForSection:(NSInteger )section
{
return [UIImage imageNamed:@"Arrowhead"];
}
- 章节Header背景颜色ForSection
- (UIColor *)ftFoldingTableView:(FTFoldingTableView *)ftTableView backgroundColorForHeaderInSection:(NSInteger )section
{
return [UIColor grayColor];
}
- 章节标题字体ForSection
- (UIFont *)ftFoldingTableView:(FTFoldingTableView *)ftTableView fontForTitleInSection:(NSInteger )section
{
return [UIFont boldSystemFontOfSize:16];
}
- 章节描述字体ForSection
- (UIFont *)ftFoldingTableView:(FTFoldingTableView *)ftTableView fontForDescriptionInSection:(NSInteger )section
{
return [UIFont systemFontOfSize:13];
}
- 章节标题文字颜色ForSection
- (UIColor *)ftFoldingTableView:(FTFoldingTableView *)ftTableView textColorForTitleInSection:(NSInteger )section
{
return [UIColor whiteColor];
}
- 章节描述文字颜色ForSection
- (UIColor *)ftFoldingTableView:(FTFoldingTableView *)ftTableView textColorForDescriptionInSection:(NSInteger )section
{
return [UIColor whiteColor];
}
安装
手动
- 克隆此仓库。
- 简单地将 '/FTFoldingTableViewLib' 文件夹放入你的项目。
- 享受吧!
CocoaPods
FTFoldingTableView 通过 CocoaPods 提供。要安装它,只需将以下行添加到你的 Podfile
pod 'FTFoldingTableView'
需要注意的
- 我花了两天时间完成这个项目,然后上传到 Cocoapods,因此我没有足够的时间测试它;如果你有任何问题,请告诉我。我将在不久的将来填写这个 README。