我有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,但是很困惑
任何建议
发布于 2011-06-29 20:35:21
如果确实需要,可以查看UIView的contentScaleFactor属性来在设备上的点和像素之间进行转换。
https://stackoverflow.com/questions/6520502
复制相似问题