HoloTableViewMGPlugin
Example
To run the example project, clone the repo, and run pod install from the Example directory first.
What's for
HoloTableViewMGPlugin is a plugin for HoloTableView framework, which provide the swip actions support for MGSwipeTableCell.
By using HoloTableViewMGPlugin, you can use all the methods of MGSwipeTableCell with HoloTableRowMaker.
To use it, simply make sure you use MGSwipeTableCell and import this plugin.
Usage
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...Installation
HoloTableViewMGPlugin is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'HoloTableViewMGPlugin'Author
gonghonglou, [email protected]
License
HoloTableViewMGPlugin is available under the MIT license. See the LICENSE file for more info.