Skip to content

Instantly share code, notes, and snippets.

@BramYeh
Created April 29, 2017 19:35
Show Gist options
  • Save BramYeh/add5dfba7fa7977a7d7adba0764e6285 to your computer and use it in GitHub Desktop.
Save BramYeh/add5dfba7fa7977a7d7adba0764e6285 to your computer and use it in GitHub Desktop.
sample: make existed cells support swipe-operation
- (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