//添加手势
UIPanGestureRecognizer * panGestureRecognizer = [[UIPanGestureRecognizeralloc]initWithTarget:selfaction:@selector(doHandlePanAction:)];
[self.btn_shopaddGestureRecognizer:panGestureRecognizer];
- (void)doHandlePanAction:(UIPanGestureRecognizer *)paramSender{
//单例中封装成公共方法
[[CommFunsharedInstance]handlePanAction:paramSenderonSuperView:self.view];
NSLog(@"X:%f;Y:%f",paramSender.view.center.x,paramSender.view.center.y);
}
#pragma mark - 购物车全屏滑动
- (void)handlePanAction:(UIPanGestureRecognizer *)paramSender onSuperView:(UIView *)superView
{
CGPoint point = [paramSendertranslationInView:superView];
paramSender.view.center =CGPointMake(paramSender.view.center.x + point.x, paramSender.view.center.y + point.y);
[paramSender setTranslation:CGPointMake(0,0) inView:superView];
if (paramSender.state ==UIGestureRecognizerStateEnded) {
if (paramSender.view.center.x <= f_CalcRealWidthByiPhone6(100)/2) {
if (paramSender.view.center.y <= f_CalcRealHeightByiPhone6((100)/2)) {
paramSender.view.center=CGPointMake(f_CalcRealWidthByiPhone6(100)/2,f_CalcRealHeightByiPhone6((100)/2));
}elseif (paramSender.view.center.y >=ScreenHeight - 110 -f_CalcRealHeightByiPhone6((100)/2)) {
paramSender.view.center=CGPointMake(f_CalcRealWidthByiPhone6(100)/2,ScreenHeight - 110 -f_CalcRealHeightByiPhone6((100)/2));
}else
{
paramSender.view.center=CGPointMake(f_CalcRealWidthByiPhone6(100)/2, paramSender.view.center.y + point.y);
}
}
elseif (paramSender.view.center.x >=ScreenWidth - f_CalcRealWidthByiPhone6(100)/2){
if (paramSender.view.center.y <= f_CalcRealHeightByiPhone6((100)/2)) {
paramSender.view.center =CGPointMake(ScreenWidth -f_CalcRealWidthByiPhone6(100)/2,f_CalcRealHeightByiPhone6((100)/2));
}elseif (paramSender.view.center.y >=ScreenHeight - 110 -f_CalcRealHeightByiPhone6((100)/2)) {
paramSender.view.center =CGPointMake(ScreenWidth -f_CalcRealWidthByiPhone6(100)/2,ScreenHeight - 110 -f_CalcRealHeightByiPhone6((100)/2));
}else
{
paramSender.view.center =CGPointMake(ScreenWidth -f_CalcRealWidthByiPhone6(100)/2, paramSender.view.center.y + point.y);
}
}
else
{
if (paramSender.view.center.y <= f_CalcRealHeightByiPhone6((100)/2)) {
paramSender.view.center =CGPointMake(paramSender.view.center.x + point.x,f_CalcRealHeightByiPhone6((100)/2));
}elseif (paramSender.view.center.y >=ScreenHeight - 110 -f_CalcRealHeightByiPhone6((100)/2)) {
paramSender.view.center =CGPointMake(paramSender.view.center.x + point.x,ScreenHeight - 110 -f_CalcRealHeightByiPhone6((100)/2));
}
else{
if (paramSender.view.center.x <=ScreenWidth/2) {
paramSender.view.center=CGPointMake(f_CalcRealWidthByiPhone6(100)/2, paramSender.view.center.y + point.y);
}else
{
paramSender.view.center =CGPointMake(ScreenWidth -f_CalcRealWidthByiPhone6(100)/2, paramSender.view.center.y + point.y);
}
}
}
}
}