Created
April 29, 2017 19:35
-
-
Save BramYeh/add5dfba7fa7977a7d7adba0764e6285 to your computer and use it in GitHub Desktop.
sample: make existed cells support swipe-operation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)containerViewPanGestureRecognized:(UIPanGestureRecognizer *)gestureRecognizer | |
{ | |
switch (gestureRecognizer.state) { | |
case UIGestureRecognizerStateBegan: { | |
self.originalLocation = [gestureRecognizer locationInView:self.contentView]; | |
break; | |
} | |
case UIGestureRecognizerStateChanged: { | |
CGFloat newX = [gestureRecognizer locationInView:self].x - self.originalLocation.x; | |
self.contentView.frame = self.targetContentViewFrame = ({ | |
CGRect frame = self.contentView.frame; | |
frame.origin.x = newX; | |
frame; | |
}); | |
break; | |
} | |
case UIGestureRecognizerStateEnded: { | |
// ... do animation or operation here | |
} | |
break; | |
} | |
default: | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment