积分与像素ios

时间:2011-06-29 12:17:59

标签: iphone ipad pixel cgpoint

我有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,但感到困惑

任何建议

1 个答案:

答案 0 :(得分:4)

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