手势 UISwipeGestureRecognizer 轻扫手势
UISwipeGestureRecognizer * swipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeGesture:)];
轻扫方向
UISwipeGestureRecognizerDirectionRight
UISwipeGestureRecognizerDirectionLeft
UISwipeGestureRecognizerDirectionUp
UISwipeGestureRecognizerDirectionDown
设置轻扫方向,让左右方向都存在 只要枚举值中又左移运算符,代表枚举值可以通过按位或 | 让多个枚举值存在
warning :::::上下 和左右方向 在一个手势识别器中不能同时存在
如果想要上下左右四个方法都有,就要创建两个轻扫手势对象,一个支持上下,一个支持左右.
swipeGesture.direction = UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight ;
[redView addGestureRecognizer:swipeGesture];
[swipeGesture release];
- (void)swipeGesture :(UISwipeGestureRecognizer *)swipeGesture
{
NSLog(@"%u", swipeGesture.direction);
swipeGesture.view.backgroundColor = [UIColor random];
}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。