-
Notifications
You must be signed in to change notification settings - Fork 71
/
RMSwipeTableViewCell.h
119 lines (97 loc) · 4.5 KB
/
RMSwipeTableViewCell.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//
// RMSwipeTableViewCell.h
// RMSwipeTableView
//
// Created by Rune Madsen on 2012-11-24.
// Copyright (c) 2015 The App Boutique. All rights reserved.
//
@import UIKit;
typedef NS_ENUM(NSUInteger, RMSwipeTableViewCellRevealDirection) {
RMSwipeTableViewCellRevealDirectionNone = -1, // disables panning
RMSwipeTableViewCellRevealDirectionBoth = 0,
RMSwipeTableViewCellRevealDirectionRight = 1,
RMSwipeTableViewCellRevealDirectionLeft = 2,
};
typedef NS_ENUM(NSUInteger, RMSwipeTableViewCellAnimationType) {
RMSwipeTableViewCellAnimationTypeEaseInOut = 0 << 16,
RMSwipeTableViewCellAnimationTypeEaseIn = 1 << 16,
RMSwipeTableViewCellAnimationTypeEaseOut = 2 << 16,
RMSwipeTableViewCellAnimationTypeEaseLinear = 3 << 16,
RMSwipeTableViewCellAnimationTypeBounce = 4 << 16, // default
};
@protocol RMSwipeTableViewCellDelegate;
@interface RMSwipeTableViewCell : UITableViewCell <UIGestureRecognizerDelegate>
/**
* Customizable subview that is revealed when the user pans
*/
@property (nonatomic, strong) UIView *backView;
/**
* Determines the direction that swiping is enabled for.
* Default is RMSwipeTableViewCellRevealDirectionBoth.
*/
@property (nonatomic, readwrite) RMSwipeTableViewCellRevealDirection revealDirection;
/**
* Determines the animation that occurs when panning ends.
* Default is RMSwipeTableViewCellAnimationTypeBounce.
*/
@property (nonatomic, readwrite) RMSwipeTableViewCellAnimationType animationType;
/**
* Determines the animation duration when the cell's contentView animates back.
* Default is 0.2f.
*/
@property (nonatomic, readwrite) CGFloat animationDuration;
/**
* Override this property at any point to stop the cell contentView from animation back into place on touch ended. Default is YES.
* This is useful in the swipeTableViewCellWillResetState:fromLocation: delegate method.
* Note: it will reset to YES in prepareForReuse.
*/
@property (nonatomic, readwrite) BOOL shouldAnimateCellReset;
/**
* When panning/swiping the cell's location is set to exponentially decay. The elasticity (also know as rubber banding) matches that of a UIScrollView/UITableView.
* Default is YES
*/
@property (nonatomic, readwrite) BOOL panElasticity;
/**
* This determines the exponential decay of the pan. By default it matches that of UIScrollView.
* Default is 0.55f.
*/
@property (nonatomic, readwrite) CGFloat panElasticityFactor;
/**
* When using panElasticity this property allows you to control at which point elasticitykicks in.
* Default is 0.0f
*/
@property (nonatomic, readwrite) CGFloat panElasticityStartingPoint;
/**
* The color of the back view, visible when swiping the cell's contentView
* Default is [UIColor colorWithWhite:0.92 alpha:1]
*/
@property (nonatomic, strong) UIColor *backViewbackgroundColor;
/**
* The methods declared by the RMSwipeTableViewCellDelegate protocol allows you to respond
* to optional messages from the cell regarding it's interaction and animation behaviour
*/
@property (nonatomic, assign) id <RMSwipeTableViewCellDelegate> delegate;
// The below instance methods provide behaviour that can be overriden in subclasses
-(void)handlePanGesture:(UIPanGestureRecognizer *)panGestureRecognizer;
-(void)didStartSwiping;
-(BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)panGestureRecognizer;
-(void)animateContentViewForPoint:(CGPoint)point velocity:(CGPoint)velocity;
-(void)resetCellFromPoint:(CGPoint)point velocity:(CGPoint)velocity;
-(UIView*)backView;
-(void)cleanupBackView;
@end
@protocol RMSwipeTableViewCellDelegate <NSObject>
@optional
-(void)swipeTableViewCellDidStartSwiping:(RMSwipeTableViewCell*)swipeTableViewCell;
-(void)swipeTableViewCell:(RMSwipeTableViewCell*)swipeTableViewCell didSwipeToPoint:(CGPoint)point velocity:(CGPoint)velocity;
-(void)swipeTableViewCellWillResetState:(RMSwipeTableViewCell*)swipeTableViewCell fromPoint:(CGPoint)point animation:(RMSwipeTableViewCellAnimationType)animation velocity:(CGPoint)velocity;
-(void)swipeTableViewCellDidResetState:(RMSwipeTableViewCell*)swipeTableViewCell fromPoint:(CGPoint)point animation:(RMSwipeTableViewCellAnimationType)animation velocity:(CGPoint)velocity;
/**
* Defaults to YES. The backView is recreated everytime the state is about to reset.
*
* @param swipeTableViewCell The swipeable cell
*
* @return A boolean value that informs the cell the cell whether to cleanup.
*/
-(BOOL)swipeTableViewCellShouldCleanupBackView:(RMSwipeTableViewCell*)swipeTableViewCell;
@end