HoloTableViewMGPlugin 2.0.0

HoloTableViewMGPlugin 2.0.0

gonghonglou维护。



 
依赖项
HoloTableView>= 0
MGSwipeTableCell>= 0
 

  • 作者
  • gonghonglou

HoloTableViewMGPlugin

CI Status Version License Platform

示例

要运行示例项目,请克隆仓库,然后首先从示例目录运行pod install

功能

HoloTableViewMGPlugin是HoloTableView框架的一个插件,该框架为MGSwipeTableCell提供了滑动操作支持。

通过使用HoloTableViewMGPlugin,您可以使用HoloTableRowMaker与所有MGSwipeTableCell的方法。

要使用它,只需确保您使用MGSwipeTableCell并导入此插件。

使用方法

UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
[self.view addSubview:tableView];

[self.tableView holo_makeRows:^(HoloTableViewRowMaker * _Nonnull make) {
    // example 1
    make.row(ExampleMGSwipeTableCell.class).model(NSDictionary.new)
    .canSwipe(YES)
    .makeSwipButtons(^(HoloTableRowMGMaker * _Nonnull make) {
        make.direction(MGSwipeDirectionLeftToRight).title(@"Left").backgroundColor(UIColor.redColor);
        make.direction(MGSwipeDirectionRightToLeft).title(@"Right").backgroundColor(UIColor.redColor);

        make.direction(MGSwipeDirectionRightToLeft).title(@"Right2").backgroundColor(UIColor.redColor)
        .callback(^BOOL(MGSwipeTableCell * _Nonnull cell) {
            NSLog(@"tag Right2 swip button");
            return YES;
        });
    });
    
    // example 2
    make.row(ExampleMGSwipeTableCell.class).model(NSDictionary.new)
    .canSwipeHandler(^BOOL(MGSwipeTableCell * _Nonnull cell, MGSwipeDirection direction, CGPoint fromPoint) {
        return YES;
    })
    .swipeButtonsHandler(^NSArray<UIView *> * _Nonnull(MGSwipeTableCell * _Nonnull cell, MGSwipeDirection direction, MGSwipeSettings * _Nonnull swipeSettings, MGSwipeExpansionSettings * _Nonnull expansionSettings) {
        if (direction == MGSwipeDirectionLeftToRight) {
            return @[[MGSwipeButton buttonWithTitle:@"Left" backgroundColor:UIColor.redColor]];
        } else {
            return @[[MGSwipeButton buttonWithTitle:@"Right" backgroundColor:UIColor.redColor]];
        }
    })
    .willBeginSwipingHandler(^(MGSwipeTableCell * _Nonnull cell) {
        NSLog(@"begin swiping: %@", cell);
    })
    .willEndSwipingHandler(^(MGSwipeTableCell * _Nonnull cell) {
        NSLog(@"end swiping: %@", cell);
    });
}];

[self.tableView reloadData];

// etc...

安装

HoloTableViewMGPlugin 通过 CocoaPods 提供。要安装,只需在您的 Podfile 中添加以下行

pod 'HoloTableViewMGPlugin'

作者

gonghonglou, [email protected]

许可

HoloTableViewMGPlugin 采用 MIT 许可协议提供。更多信息请查看 LICENSE 文件。