zoukankan      html  css  js  c++  java
  • cell左右滑动展开更多按钮-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 

  • 相关阅读:
    zz目标检测
    zz——Recent Advances on Object Detection in MSRA
    zz2019年主动学习有哪些进展?答案在这三篇论文里
    《动手学深度学习》摘要
    P3157 [CQOI2011]动态逆序对 CDQ分治
    数学基础————长期更新
    BZOJ 3639: Query on a tree VII LCT+set维护子树信息
    3065: 带插入区间K小值 树套树 + 替罪羊树 + 权值线段树
    BZOJ 3637: Query on a tree VI LCT + 子树信息 + 点权转边权
    [BJOI2014]大融合 LCT维护子树信息
  • 原文地址:https://www.cnblogs.com/hxwj/p/4960773.html
Copyright © 2011-2022 走看看