- (void)Action:(UIPanGestureRecognizer *)recognizer {
CGPoint translationPoint = [recognizer translationInView:self.view];
CGPoint center = recognizer.view.center;
recognizer.view.center = CGPointMake(center.x + translationPoint.x, center.y + translationPoint.y);
[recognizer setTranslation:CGPointZero inView:self.view];
}
UIPanGestureRecognizer* ges = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(Action:)];
gesture.minimumNumberOfTouches = 1;
gesture.maximumNumberOfTouches = 1;
[btn addGestureRecognizer:ges];
网友评论