我有这些大小的圆圈,它们使用 UISlider 改变并在触摸时绘制。
现在,我正在尝试给它一个新的样式,让它在触摸时如何在屏幕上绘制,就像这样,当用户按住触摸(例如他在中间大小的圆圈上)时,它将开始形式最小尺寸并停在当前尺寸,但是当用户快速点击屏幕时,无论尺寸是多少,它都会绘制最小尺寸...
我将如何做到这一点?
这是我当前的代码: 在 touchesBegan 上:
if(!touchSwiped) {
UIGraphicsBeginImageContext(self.view.frame.size);
[drawView.image drawInRect:CGRectMake(0, 0, 768, 1024)];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context, lineWidth);
CGContextSetRGBStrokeColor(context, color1, color2, color3, alpha);
CGContextSetBlendMode(context, blendMode);
CGContextMoveToPoint(context, endingPoint.x, endingPoint.y);
CGContextAddLineToPoint(context, endingPoint.x, endingPoint.y);
CGContextStrokePath(context);
CGContextFlush(context);
drawView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
谢谢!
最佳答案
UILongPressGestureRecognizer
可能是您正在寻找的。p>
关于iOS:长按手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8440346/