MGSwipeTableCell

MGSwipeTableCell是一个UITableViewCell子类,

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

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

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

  1 #pragma mark - MGSwipeTableCellDelegate

复制代码
 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

03181831_9nCp.gif 
Clip transition

03181831_n3Mu.gif 
3D transition

03181832_JCOL.gif 
Static transition

03181832_kvEI.gif 
Drag transition

03181832_i37d.gif 

转载于:https://my.oschina.net/u/1244672/blog/539011

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值