2

我有 uiview ,我放大和缩小它

我将它与 pinchRecognizerMeasure 使用关联

pinchRecognizerMeasure = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(MeasureAndDraw:)];
[pinchRecognizerMeasure setDelegate:self];
[DrawLine addGestureRecognizer:pinchRecognizerMeasure];
[pinchRecognizerMeasure release];

MeasureAndDraw 的代码

    // get position of touches, for example:
    NSUInteger num_touches = [pinchRecognizerMeasure numberOfTouches];

    // save locations to some instance variables, like `CGPoint location1, location2;`
    if (num_touches >= 1) {

        DrawLine.startPoint = [pinchRecognizerMeasure locationOfTouch:0 inView:DrawLine];
    }
    if (num_touches >= 2) {

        DrawLine.endPoint = [pinchRecognizerMeasure locationOfTouch:1 inView:DrawLine];
    }

startPoint , endPoint 是 CGPoint ,我想得到它的等效像素

我该怎么做是正确的

startPoint.X * DrawLine.contentScaleFactor 获取 pixl x 坐标或者我该怎么做

我读了http://developer.apple.com/library/ios/#documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GraphicsDrawingOverview/GraphicsDrawingOverview.html,但感到困惑

任何建议

4

1 回答 1

4

如果您确实需要,请查看UIViewcontentScaleFactor的属性以在设备上的点和像素之间进行转换。

于 2011-06-29T12:35:21.277 回答