Open taojeff opened 7 years ago
(void)panAction:(UIPanGestureRecognizer *)gestureRecognizer { /// 获取通过的点 CGPoint p = [gestureRecognizer translationInView:self];
if ([gestureRecognizer state] == UIGestureRecognizerStateBegan) // 开始滑动 {
} else if ([gestureRecognizer state] == UIGestureRecognizerStateChanged) // 坐标改变中 { if (self.originX + p.x <= 0 || self.originX + p.x >= screenW - self.width) { if (self.originY + p.y <= GMK_NavBar_H || self.originY + p.y >= screenH - GMK_BottomBar_H - self.height - 44) { [self setTransform:CGAffineTransformTranslate([self transform], 0, 0)]; } else { [self setTransform:CGAffineTransformTranslate([self transform], 0, p.y)]; [gestureRecognizer setTranslation:CGPointZero inView:self]; } } else if (self.originY + p.y <= GMK_NavBar_H || self.originY + p.y >= screenH - GMK_BottomBar_H - self.height - 44) { if (self.originX + p.x <= 0 || self.originX + p.x >= screenW - self.width) { [self setTransform:CGAffineTransformTranslate([self transform], 0, 0)]; } else { [self setTransform:CGAffineTransformTranslate([self transform], p.x, 0)]; [gestureRecognizer setTranslation:CGPointZero inView:self]; } } else { [self setTransform:CGAffineTransformTranslate([self transform], p.x, p.y)]; [gestureRecognizer setTranslation:CGPointZero inView:self]; }
}
博主,如果我想让拖动的空间距离四周有一定的间距我改如何去调整,好比我默认情况下空间距离X、Y都有5单位的距离 这个时候我再滑动的move中如何去修改设置这个值