iOS 从上一个比例缩放开始

iOS Pinch Zoom Start from Previous Scale

我想 pinch/zoom 以当前比例开始缩放。我试过以下代码:

@objc func pinchedView(recognizer:UIPinchGestureRecognizer) {

    if (recognizer.state == .ended)  {
        lastScale = 1.0
        return
    }

    let scale = 1.0 - (lastScale - recognizer.scale)
    let zoomInAction = SKAction.scale(to: cameraNode.yScale + scale, duration: 0.25)
    lastScale = recognizer.scale
    cameraNode.run(zoomInAction)
}

问题是无论我怎么捏,它都越来越小。我该如何纠正?

我认为您可能希望在手势开始时将 lastScale 初始化为 1.0。

看看这个问题的accepted answer