SwipeTableCell.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // SwipeTableCell.h
  3. // SwipeTableView
  4. //
  5. // Created by zhao on 16/8/11.
  6. // Copyright © 2016年 zhaoName. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "SwipeButton.h"
  10. #import "SwipeView.h"
  11. typedef NS_ENUM(NSUInteger, SwipeTableCellStyle)
  12. {
  13. SwipeTableCellStyleRightToLeft = 0, /**< 右滑*/
  14. SwipeTableCellStyleLeftToRight , /**< 左滑*/
  15. SwipeTableCellStyleBoth, /**< 左滑、右滑都有*/
  16. };
  17. @class SwipeTableCell;
  18. @protocol SwipeTableViewCellDelegate <NSObject>
  19. @required
  20. /**
  21. * 设置cell的滑动按钮的样式 (左滑、右滑、左滑右滑都有)
  22. *
  23. * @param indexPath cell的位置
  24. */
  25. - (SwipeTableCellStyle)tableView:(UITableView *)tableView styleOfSwipeButtonForRowAtIndexPath:(NSIndexPath *)indexPath;
  26. /**
  27. * 左滑cell时显示的button
  28. *
  29. * @param indexPath cell的位置
  30. */
  31. - (NSArray<SwipeButton *> *)tableView:(UITableView *)tableView leftSwipeButtonsAtIndexPath:(NSIndexPath *)indexPath;
  32. /**
  33. * 右滑cell时显示的button
  34. *
  35. * @param indexPath cell的位置
  36. */
  37. - (NSArray<SwipeButton *> *)tableView:(UITableView *)tableView rightSwipeButtonsAtIndexPath:(NSIndexPath *)indexPath;
  38. @optional
  39. /**
  40. * 当滑动手势结束后,点击cell是否隐藏swipeView,即cell自动回复到最初状态。默认YES
  41. */
  42. - (BOOL)tableView:(UITableView *)tableView hiddenSwipeViewWhenTapCellAtIndexPath:(NSIndexPath *)indexPath;
  43. /**
  44. * 点击按钮隐藏SwipeView 默认YES
  45. *
  46. * @param cell 按钮所在的cell
  47. *
  48. * @return 是否隐藏
  49. */
  50. - (BOOL)hideSwipeViewWhenClickSwipeButtonAtCell:(SwipeTableCell *)cell;
  51. /**
  52. * 设置swipeView的弹出样式
  53. */
  54. - (SwipeViewTransfromMode)tableView:(UITableView *)tableView swipeViewTransformModeAtIndexPath:(NSIndexPath *)indexPath;
  55. /**
  56. * 设置swipeButton 距SwipeTableCell上左下右的间距
  57. *
  58. * @warn 值要>0 否则可能导致显示不全
  59. */
  60. - (UIEdgeInsets)tableView:(UITableView *)tableView swipeButtonEdgeAtIndexPath:(NSIndexPath *)indexPath;
  61. @end
  62. @class SwipeTableViewDelegate;
  63. @interface SwipeTableCell : UITableViewCell
  64. @property (nonatomic, weak) id<SwipeTableViewCellDelegate> swipeDelegate;
  65. /** swipeButton下的背景色 默认透明色*/
  66. @property (nonatomic, strong) UIColor *swipeOverlayViewBackgroundColor;
  67. /** 当结束滑动手势时,显示或隐藏SwipeView的临界值 范围:0-1,默认0.5*/
  68. @property (nonatomic, assign) CGFloat swipeThreshold;
  69. /** 是否允许多个cell同时滑动 默认NO*/
  70. @property (nonatomic, assign) BOOL isAllowMultipleSwipe;
  71. /** 滚动TableView时是否隐藏swipeView 默认YES*/
  72. @property (nonatomic, assign, readonly) BOOL hideSwipeViewWhenScrollTableView;
  73. /** 点击按钮隐藏SwipeView 默认YES*/
  74. @property (nonatomic, assign) BOOL hideSwipeViewWhenClickSwipeButton;
  75. /** 是否允许拉伸 默认NO(模仿系统邮件自带拉伸删除)*/
  76. @property (nonatomic, assign) BOOL isAllowExpand;
  77. /** 拉伸按钮的下标*/
  78. @property (nonatomic, assign) NSInteger expandSwipeBtnAtIndex;
  79. /** 拉伸临界值 1-2,默认1.5*/
  80. @property (nonatomic, assign) CGFloat expandThreshold;
  81. /**
  82. * 隐藏滑动按钮 即将cell恢复原状
  83. *
  84. * @param isAnimation 是否隐藏
  85. */
  86. - (void)hiddenSwipeAnimationAtCell:(BOOL)isAnimation;
  87. /**
  88. * 更改滑动按钮的内容 如置顶变成取消置顶
  89. */
  90. - (void)refreshButtonContent;
  91. @end