MGSwipeTableCell

MGSwipeTableCell是一个UITableViewCell子类, git

它实现了左,右滑动展开更多按钮用来实现一些相关操做就和QQ好友列表滑动展开的按钮同样,封装的很好,动画效果也处理很到位,废话很少说,咱们来看下它的简单集成 github

1.写一个类来继承他,和UITableView同样的使用 编程

2.设置代理delegate而且实现协议MGSwipeTableCellDelegate的一些方法 数组

  1 #pragma mark - MGSwipeTableCellDelegate app

复制代码
 2 
 3 - (NSArray *)swipeTableCell:(MGSwipeTableCell *)cell swipeButtonsForDirection:(MGSwipeDirection)direction swipeSettings:(MGSwipeSettings *)swipeSettings expansionSettings:(MGSwipeExpansionSettings *)expansionSettings {
 4      // 左边
 5      expansionSettings.fillOnTrigger = YES;
 6      if (direction == MGSwipeDirectionLeftToRight) {
 7 
 8          // 返回的数组必须是button类型的
 9           return @[[MGSwipeButton buttonWithTitle: @" 哈哈 " icon:nil backgroundColor:[UIColor redColor] padding: 15 callback:^BOOL(MGSwipeTableCell * sender){
10             NSLog( @" Convenience callback received (left). ");
11              return YES;
12         }],[MGSwipeButton buttonWithTitle: @" 哈哈 " icon:nil backgroundColor:[UIColor redColor] padding: 15 callback:^BOOL(MGSwipeTableCell * sender){
13             NSLog( @" Convenience callback received (left). ");
14              return YES;
15         }]];
16     }
17      // 右边
18       else {
19         UIButton *view = [[UIButton alloc]initWithFrame:CGRectMake( 003030)];
20         view.userInteractionEnabled = YES;
21         view.backgroundColor = [UIColor yellowColor];
22          return @[view];
23     }
24 }
25 
26 
27 - (BOOL)swipeTableCell:(MGSwipeTableCell *)cell tappedButtonAtIndex:(NSInteger)index direction:(MGSwipeDirection)direction fromExpansion:(BOOL)fromExpansion {
28     NSLog( @" %ld:%ld  ",index,direction);
29      return YES;
30 }
复制代码

 

3.能够运行查看效果了 测试

github连接:https://github.com/MortimerGoro/MGSwipeTableCell  动画

 


MGSwipeTableCell是UITableViewCell的子类,用多种过渡方式展现可点击的按钮,该库兼容全部不一样的方式来建立UITableViewCell:系统预置的类型、以编程方式建立cell......

测试环境:Xcode 5.0,iOS 6.0以上

转换demo
Border transition

 
Clip transition

 
3D transition

 
Static transition

 
Drag transition

 
相关文章
相关标签/搜索