我需要为用户提供裁剪图像的功能。我在一个视图上显示uiimageview在那个视图上显示的是另一个像小框一样可移动的视图。在移动方框时,它会给我坐标据此我将从uiimageview创建一个新图像。通过这种方式,我给出了一个裁剪图像的功能。
到目前为止,我给了一个固定的高度和宽度的框来裁剪,但现在我需要给一个功能,如2手指触摸,我的裁剪框会根据我的手指的位置调整大小,就像苹果的ScrollviewSuite的例子。我正在做以下事情:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
NSUInteger tapCount = [touch tapCount];
UITapGestureRecognizer *twoFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerTap:)];
[twoFingerTap setNumberOfTouchesRequired:2];
[newView addGestureRecognizer:twoFingerTap];
CGPoint touchLocation = [touch locationInView:self.view];
oldX = touchLocation.x;
oldY = touchLocation.y;
}
- (void)handleTwoFingerTap:(UIGestureRecognizer *)gestureRecognizer
{
CGRect frame = newView.frame; \newframe is the crop box
frame.size.height += 100;
newView.frame = frame;
}
但是这样我只能以静态的方式增加高度。我应该怎么做来获取两个手指触摸和坐标?任何帮助都将不胜感激。谢谢你。
handleTwoFingerTap隐藏自我。视图和可见滚动视图意味着你需要一个uiview和一个滚动视图。scrollview for zoom