SWRevealTableViewCell 是 UITableViewCell 的子类,可以轻松显示基于用户滑动手势或开发者程序化操作的左右按钮。与 iOS8 邮件应用类似,但增加了更多功能。
http://youtu.be/jlaWQsWinoU (新)
仓库包含以下示例项目,可用于模板或测试目的
SWRevealTableViewCell 仓库尝试提供一个更新的 cocoaPods 文件和一致的标签版本号,但在 cocoapods-specs 仓库中没有活跃更新。
安装它的最简单方法是将其复制到您的项目中
在您的项目上
为您的 tableView 注册 SWRevealTableViewCell
[tableView registerClass:[SWRevealTableViewCell class] forCellReuseIdentifier:RevealCellReuseIdentifier];
创建单元格实例
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
SWRevealTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:RevealCellReuseIdentifier forIndexPath:indexPath];
cell.dataSource = self;
.
.
}
提供按钮项
- (NSArray*)rightButtonItemsInRevealTableViewCell:(SWRevealTableViewCell *)revealTableViewCell
{
SWCellButtonItem *item1 = [SWCellButtonItem itemWithTitle:@"Delete" handler:^(SWCellButtonItem *item, SWRevealTableViewCell *cell)
{
NSLog( @"Delete");
}];
item1.backgroundColor = [UIColor redColor];
item1.tintColor = [UIColor whiteColor];
item1.width = 75;
return @[item1];
}
左/右项的程序动画。位置可以是: SWCellRevealPositionLeft
,SWCellRevealPositionCenter
,SWCellRevealPositionRight
- (void)setRevealPosition:(SWCellRevealPosition)revealPosition animated:(BOOL)animated;
其他方法在 SWRevealTableViewCell.h 声明文件中有文档说明。
发布说明更新在类的主体头文件中。请参阅 SWRevealTableViewCell.h
版权(c)2013 Joan Lluch [email protected]
兹特此授权,任何人获得此软件及其相关文档(“软件”)的副本,可以不受限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并允许向软件提供者提供软件的人这样做,前提是以下条件
上述版权声明和本授权声明应包含在软件的所有副本或主要部分中。
本软件按“原样”提供,不提供任何形式的保证,包括但不仅限于对适销性、特定用途适用性和非侵权性的保证。在任何情况下,作者或版权持有人不对任何索赔、损害或其他责任承担任何责任,无论这些责任源于合同、侵权或其他,无论是否与软件、软件的使用或其他方式有关。