我正在开发一个应用程序,其中有一个功能是通过拖动底部右侧按钮来调整图像视图的大小和旋转。
我看到了一个应用程序,该应用程序具有以下功能:如果我们对角线拖动底部右侧的按钮,则会调整图像视图的大小;否则,如果我们将按钮向左或向右拖动,则会根据方向旋转图像视图。 我希望在我的应用程序中实现这个功能。
我正在努力实现单指旋转以及调整图像视图的大小。
我成功地通过拖动右下角的按钮来调整图像视图的大小。 但是我不知道如何向图像视图添加旋转。
请指导我正确的方法。
下面是调整图像视图大小的代码:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
touchStart = [[touches anyObject] locationInView:imageView];
isResizingLR = (containerVw.bounds.size.width - touchStart.x < kResizeThumbSize && containerVw.bounds.size.height - touchStart.y < kResizeThumbSize);
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
CGPoint touchPoint = [[touches anyObject] locationInView:imageView];
CGPoint previous=[[touches anyObject]previousLocationInView:imageView];
UITouch *touch = [[event allTouches] anyObject];
float deltaWidth = touchPoint.x-previous.x;
float deltaHeight = touchPoint.y-previous.y;
if (isResizingLR) {
containerVw.frame = CGRectMake(containerVw.frame.origin.x, containerVw.frame.origin.y,touchPoint.x + deltaWidth, touchPoint.y + deltaWidth);
imageView.frame = CGRectMake(imageView.frame.origin.x, imageView.frame.origin.y,touchPoint.x + deltaWidth, touchPoint.y + deltaWidth);
dragIm.frame = CGRectMake(containerVw.frame.size.width-10, containerVw.frame.size.height-10,20,20);
if (!isResizingLR) {
containerVw.center = CGPointMake(containerVw.center.x + touchPoint.x touchStart.x,containerVw.center.y + touchPoint.y - touchStart.y);
}
}