首页 > 移动平台 > 详细

IOS仿桌面拖动桌面图标

时间:2020-06-05 19:48:17      阅读:47      评论:0      收藏:0      [点我收藏+]

手势拖动

UIPanGestureRecognizer * panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self
                                                                                                    action:@selector(doMoveAction:)];

核心部分

拖到到前面还是后面的判断

                    Boolean preMove =true;
                    //判断前后移动四种情况
                    //(ex<startPoint.x && ey<startPoint.y)||(ex>startPoint.x && ey<startPoint.y) ||(ex==startPoint.x && ey<startPoint.y)
|| (ey==startPoint.y && ex <startPoint.x)
//偏差5都认为相等 CGFloat diff =10; if ((startPoint.x-ex>diff && startPoint.y-ey>diff)||(ex>(startPoint.x+diff) && (ey+diff)<startPoint.y)
||(fabs(ex-startPoint.x)<=diff && (ey+diff)<startPoint.y)|| (fabs(ey-startPoint.y)<=diff && (ex+diff) <startPoint.x) )

 

完整代码

IOS仿桌面拖动桌面图标

原文:https://www.cnblogs.com/tk55/p/13051142.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!