当用户在 IOS 中捏屏幕时,我试图放大我的画布。
我正在从 Android 翻译我的代码(有效),这是一个 snift:
focusX = gestureDetector.getFocusX();
focusY = gestureDetector.getFocusY();
enter code herecanvas.scale(mScaleFactor,mScaleFactor,focusX,focusY);
我翻译的 IOS 代码没有给出相同的结果:
- (void)onScale:(UIPinchGestureRecognizer *)gesture
{
if (gesture.state == UIGestureRecognizerStateBegan) {
CGPoint endPoint = [gesture locationInView:self];
focusX = endPoint.x;
focusY = endPoint.y;
}
}
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), focusX, focusY);
CGContextScaleCTM(UIGraphicsGetCurrentContext(), mScaleFactor, mScaleFactor)
为什么?