I am try to use UIPinchGesture to scale a simple face that I draw by bezierPath, but when I use two finger to pinch the screen (either make it bigger or smaller), it does not show me result, only when I rotate the device, then the scaled face show up, really appreciate it for your suggestion about how to fix it:
below are my code that i use to implement the pinchGesture in my faceView.swift:
func scale(gesture: UIPinchGestureRecognizer){
if gesture.state == .Changed {
scale *= gesture.scale
gesture.scale = 1
}
}
in my ViewController.swift:
@IBOutlet weak var faceView: FaceView! {
didSet{
faceView.dataSource = self
faceView.addGestureRecognizer(UIPinchGestureRecognizer(target:faceView,
action:"scale:"))
}
}
The problem shouldn't be in your code you pasted, because you know your scaling does work, it just doesn't draw it immediately. I believe you should declare FaceView's scale property with { didSet { setNeedsDisplay() } }
to update the UI every time the scale gets changed.
At this moment, the UI gets updated only when you rotate your device.