测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
发布最后发布 | 2016年11月 |
由 Andrzej Michnia,Andrzej Michnia 维护。
可自定义的滑动单元格行为。基于 MKSlidingTableViewCell,增加了几个新选项。现在您可以为抽屉和前景单元格(整个或其部分)添加可变换的行为 - 正在进行 3D 变换,为您带来美观、干净的外观,以及多个可自定义的选项。
创建符合给定结构的单元格
容器 作为 MKSlidingTableViewCell - 这是前景单元格和背景单元格的空容器。
前景 作为 MKActionTableViewCell 的子类 - 这是实际上在单元格中显示的内容。要工作,您必须设置有效的自动布局并连接出口。对于前景,如果不连接出口,只会导致前景没有 3D 变换。
actionContainer:这是主要容器(如果没有可变换,则为可选)
transformableContainer:这应该与 actionContainer 大小相同,其中所有内容都将被 3D 变换(可选)
背景 作为 MKActionTableViewCell 的子类 - 这是单元格滑动时被揭示的内容。
actionContainer:这是主要容器,其大小决定了单元格将滑动多少(必需的)
transformableContainer:这应该与 actionContainer 大小相同,其中所有内容都将被 3D 变换(可选)
当单元格准备好时,(故事板或 XIB) - 您可以创建以下类似的实际滑动单元格
Objective-C
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MKSlidingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"container"];
UITableViewCell *foregroundCell = [tableView dequeueReusableCellWithIdentifier:@"foreground"];
UITableViewCell *backgroundCell = [tableView dequeueReusableCellWithIdentifier:@"background"];
cell.foregroundView = foregroundCell;
cell.drawerView = backgroundCell;
cell.delegate = self;
//configure cells
return cell;
}
Swift
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
guard let
containerCell = tableView.dequeueReusableCellWithIdentifier("container") as? MKSlidingTableViewCell,
foregroundCell = tableView.dequeueReusableCellWithIdentifier("foreground") as? MKActionTableViewCell, // Or its subclass
drawerCell = tableView.dequeueReusableCellWithIdentifier("background") as? MKActionTableViewCell // Or its subclass
else {
return UITableViewCell()
}
containerCell.foregroundView = foregroundCell
containerCell.drawerView = drawerCell
containerCell.delegate = self
return containerCell
}
Objective-C
- (void)didSelectSlidingTableViewCell:(MKSlidingTableViewCell *)cell
{
//cell tapped!
}
Swift
func didSelectSlidingTableViewCell(cell: MKSlidingTableViewCell!) {
print("Did select")
}
Objective-C
//Add observers
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRevealDrawerViewForCell:) name:MKDrawerDidOpenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didHideDrawerViewForCell:) name:MKDrawerDidCloseNotification object:nil];
- (void)didRevealDrawerViewForCell:(NSNotification *)notification
{
MKSlidingTableViewCell *cell = notification.object;
//additional code
}
- (void)didHideDrawerViewForCell:(NSNotification *)notification
{
MKSlidingTableViewCell *cell = notification.object;
//additional code
}
此分叉和 AMKSlidingTableViewCell 的更新由 Andrzej Michnia 创建。
MKSlidingTableViewCell 由 Michael Kirk 创建,Sam Corder 提供贡献。
MKSlidingTableViewCell 可在 MIT 许可证下获得。有关更多信息,请参阅 LICENSE 文件。