iOS:长按手势

标签 ios cocoa-touch ipad uikit

enter image description here

我有这些大小的圆圈,它们使用 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 可能是您正在寻找的。

关于iOS:长按手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8440346/

相关文章:

ios - 如何使用GADRewardBasedVideoAd

ios - 使用链接创建动态单元格。

ios - 尝试在 iOS 10 中使用 xcode 8.3.3 本地化 LaunchScreen.storyboard 以支持语言时出现问题

objective-c - 找出iOS中货币的小数位数

html - 输入文本在 iPad 上闪烁

javascript - 通过 js 组合 css3 转换

ios - ABAddressBookRequestAccessWithCompletion 的最佳实践

objective-c - ios中的GDataXMLElement到原始xml字符串

iphone - 如何设置 UIScrollView 的滚动位置?

iphone - 为什么 viewDidLoad 中的 self.navigationController 为 null?