一次只允许一个UIGestureRecognizer可用

时间:2019-03-14 07:22:45

标签: ios swift uigesturerecognizer

我有一个extension UILabel { var stringLines: [String] { guard let text = text, let font = font else { return [] } let ctFont = CTFontCreateWithName(font.fontName as CFString, font.pointSize, nil) let attStr = NSMutableAttributedString(string: text) attStr.addAttribute(kCTFontAttributeName as NSAttributedString.Key, value: ctFont, range: NSRange(location: 0, length: attStr.length)) let frameSetter = CTFramesetterCreateWithAttributedString(attStr as CFAttributedString) let path = CGMutablePath() path.addRect(CGRect(x: 0, y: 0, width: self.frame.size.width, height: CGFloat.greatestFiniteMagnitude), transform: .identity) let frame = CTFramesetterCreateFrame(frameSetter, CFRangeMake(0, 0), path, nil) guard let lines = CTFrameGetLines(frame) as? [Any] else { return [] } return lines.map { line in let lineRef = line as! CTLine let lineRange: CFRange = CTLineGetStringRange(lineRef) let range = NSRange(location: lineRange.location, length: lineRange.length) return (text as NSString).substring(with: range) } } } 的列表。他们每个人都有自己的UIView。如何使唯一的UIPanGestureRecognizer一次可以拖动? 现在,如果我使用2根手指,则可以拖动2个UIView

1 个答案:

答案 0 :(得分:0)

我找到了解决方案 在UIView上使用isExclusiveTouch一次只能使一个UIGestureRecognizer可用