手势 UISwipeGestureRecognizer 轻扫手势
导读:本文共798字符,通常情况下阅读需要3分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: UISwipeGestureRecognizer * swipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeGesture:)]; 轻扫方向 UISwipeGestureRecognizerDirectionRight UISwipeGe... ...
目录
(为您整理了一些要点),点击可以直达。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];
}
手势 UISwipeGestureRecognizer 轻扫手势的详细内容,希望对您有所帮助,信息来源于网络。