[英]Trying to move UIImageView on UIPanGestureRecognizer
嗨,大家好,我正在嘗試使用UIPanGestureRecognizer上的以下代碼移動UIImageView
CGPoint pointMove;
pointMove.x = holderView.center.x + (currentPoint.x - lastPoint.x);
pointMove.y = holderView.center.y + (currentPoint.y - lastPoint.y);
holderView.center = pointMove;
lastPoint = currentPoint;
但是,這給移動不順暢帶來了混亂。 請幫我
我有一個使用UIPanGestureRecognizer
拖動圖像的最佳示例
請下載此演示並檢查它:-
https://github.com/elc/iCodeBlogDemoPhotoBoard
希望對你有幫助
這是一些相同的問題,請訪問鏈接:-
嘗試在您的代碼中更改它。
CGPoint translation = [gestureRecognizer translationInView:[holderView superview]];
[holderView setCenter:CGPointMake([piece center].x + translation.x, [piece center].y + translation.y)];
我希望這能解決您的問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.