2
我使用下面的代碼在屏幕上拖動圖像。我喜歡改變的一件事是圖像的位置。現在,該位置變爲每次觸摸,所以每次我嘗試移動它時,它都會轉換爲我的手指。我如何使它可以相對於我的手指移動?例如如果圖像位於屏幕中間,並且我將手指放在屏幕的右下角,則圖像不會轉換到我的手指。希望這是有道理的。提前致謝。更改位置UITouch
// get touch event
UITouch *touch = [[event allTouches] anyObject];
// get the touch location
CGPoint touchLocation = [touch locationInView:touch.view];
// move the image view
image.center = touchLocation;
非常感謝:) – hakimo