IKImageView:如何创建应用程序看起来像预览

时间:2013-04-27 16:56:50

标签: xcode image mouse zoom ikimageview

我正在开发一个apllication,作为一个内部有IKImageView对象的视图。我可以在图像的中心位置缩放图像,但我无法使用鼠标位置进行缩放,因为图像的“锚点”看起来像预览应用程序。

我有鼠标位置坐标(相对于图像)。

我可以使用此功能将图像置于特定点:

- (void)centerSourceImageInPoint:(NSPoint)point
{
IKImageView *theImage = sourceImageController.imageView;

NSPoint pointInView = [theImage convertImagePointToViewPoint:point];

NSRect activeRect = [sourceImageView bounds];
NSPoint origin = CGPointMake(pointInView.x - activeRect.size.width / 2, pointInView.y - activeRect.size.height / 2);

[theImage setBoundsOrigin:origin];}

e.g。如果鼠标点为(3; 3),图像将会平移,直到图像点(3; 3)位于视图的中心。

0 个答案:

没有答案