我正在開發一個應用程序,它具有通過拖動右下角的按鈕來調整圖像大小並旋轉圖像視圖的功能。如何使用單個手指旋轉和調整圖像視圖的大小
我看到一個應用程序具有的功能,如果我們拖動右下角按鈕對角圖像視圖大小已調整大小,否則,如果我們拖動按鈕的左側或右側的方向imageview已按每個方向旋轉。我希望在我的應用程序中實現此功能
我正在努力實現單指旋轉以及調整圖像視圖的大小。
我可以通過拖動右下角的按鈕來成功實現調整圖像視圖的大小。但我沒有足夠的知識將旋轉添加到圖像視圖
請以正確的方式指導我。
我添加了下面的代碼,通過拖動它的右下角來調整圖像視圖的大小。
- (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);
}
}
您如何期望僅從1點得到一個角度? – 2012-09-24 14:14:15
我看到一個應用程序。他們已經實現了這個功能。我不知道他們是如何實現的。 – thavasidurai
你有沒有得到解決方案? –