长按移动框架

作者: 喵喵嘟噜啡 | 来源:发表于2017-03-14 17:11 被阅读102次

比如先创建个button

button上加上这个长按手势

UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:selfaction:@selector(PanAnyWhere:)];

[button addGestureRecognizer: panGestureRecognizer];

长按的实现

- (void)PanAnyWhere:(UIPanGestureRecognizer*)recognizer

{

CGPoint translation = [recognizer translationInView:self.view];

recognizer.view.center=CGPointMake(recognizer.view.center.x+ translation.x,

recognizer.view.center.y+ translation.y);

[recognizer setTranslation:CGPointZeroinView:self.view];

}

相关文章

网友评论

    本文标题:长按移动框架

    本文链接:https://www.haomeiwen.com/subject/clphnttx.html