手势
来源:互联网 发布:windows7 编程看什么书 编辑:程序博客网 时间:2024/04/24 04:02
首先在view上添加手势 UIPanGestureRecognizer
UIPanGestureRecognizer *panGes = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(goAnimation:)]; [self.view addGestureRecognizer:panGes];
在滑动方法当中根据 translationInView 这个方法返回的点的正负来判断向左还是向右 大于0说明向左,小于0说明向右
UIPanGestureRecognizer *pan = (UIPanGestureRecognizer *)sender; CGPoint point = [pan translationInView:self.view]; if (point.x>0) {}
0 0