简体   繁体   English

在图形上下文中将数据放大一倍

[英]zoom in graphic context by a factor around a pivot value

I am trying to zoom in my canvas when the user pinches the screen In IOS. 当用户在IOS中捏屏时,我正在尝试放大画布。

I am translating my code from Android(which works), here's a snift: 我正在从Android(可运行)翻译我的代码,这是一个小巧的做法:

focusX = gestureDetector.getFocusX();
focusY = gestureDetector.getFocusY();

enter code herecanvas.scale(mScaleFactor,mScaleFactor,focusX,focusY);

my translated IOS code doesn't give the same results: 我翻译的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)

Why? 为什么?

I found the problem, CGContextTranslateCTM is redundant. 我发现了问题,CGContextTranslateCTM是多余的。 Also I had another problem , the scale factor of the recognizer in Android is relative whereas in IOS it's absolute. 另外我还有一个问题,Android中识别器的比例因子是相对的,而在IOS中则是绝对的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM