一款 iOS 7 风格的滑动表格单元格。在您的表格视图中使用 MKSlidingTableViewCell,您可以将任何视图设置为“抽屉视图”,然后设置揭示量来指定在拖拽时滚动视图将停留在何处。由于 MKSlidingTableViewCell 使用滚动视图作为单元格内容的容器,因此在滑动单元格时,它将像预期的那样跟踪和弹跳。如下面的截图所示,您可以模仿 iOS 7,也可以自定义您想要的任何方式!
- (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.drawerRevealAmount = 146;
cell.delegate = self;
//configure cells
return cell;
}
- (void)didSelectSlidingTableViewCell:(MKSlidingTableViewCell *)cell
{
//cell tapped!
}
//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
}
MKSlidingTableViewCell 是由 Michael Kirk 创建的,并有 Sam Corder 的贡献。
MKSlidingTableViewCell 可以在 MIT 许可下使用。有关更多信息,请参阅 LICENSE 文件。