UIView Multiple Transform

时间:2018-08-22 13:49:32

标签: ios swift uiview transform gestures

I have trouble with rotating and scalling my UIView and I haven't found any solution.

Here is sample:

@IBAction func rotateMazeView(_ sender: UIRotationGestureRecognizer) {
    mazeView.transform = mazeView.transform.rotated(by: sender.rotation)
}
@IBAction func scaleMazeView(_ sender: UIPinchGestureRecognizer) {

    let scaleFactor = sender.scale

    mazeView.transform = mazeView.transform.concatenating((CGAffineTransform(scaleX: scaleFactor, y: scaleFactor)))
}

When I rotate this view, rotation speed is unbelievable fast. The same problem with scale function. Why I don't use just view.transform = CGAffineTransform(scaleX: scaleFactor, y: scaleFactor)? In this case, when the view was rotate and I am starting to scale, the view return to origin position.

I need to implement difficult transforming with this view. Hope that the answer help many other people.

0 个答案:

没有答案