您必须在平移手势方法中设置条件
CGPoint translatedPoint = [(UIPanGestureRecognizer*)sender translationInView:your view];
if([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateBegan) {
firstX = [your image center].x;//firstX and FirstY is CGFLoat...
firstY = [your image center].y;
}
if([(UIPanGestureRecognizer *)sender state] == UIGestureRecognizerStateEnded)
{
}
translatedPoint = CGPointMake(firstX+translatedPoint.x, firstY+translatedPoint.y);
if(translatedPoint.x < 0 || translatedPoint.x > 320)
{
set your image frame
}
else if(translatedPoint.y < 0 || translatedPoint.y > 480)
{
set your image frame
}
// [your image setCenter:translatedPoint];
you can change boundaries in above conditions
让我知道它是否工作......!!!快乐编码.!!!!