ios手势识别之轻扫

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ios手势识别之轻扫相关的知识,希望对你有一定的参考价值。

 1 - (void)viewDidLoad
 2 {
 3     [super viewDidLoad];
 4     
 5     // 向上
 6     UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] init];
 7     // 设置轻扫的方向
 8     swipe.direction = UISwipeGestureRecognizerDirectionUp;
 9     [self.customView addGestureRecognizer:swipe];
10     [swipe addTarget:self action:@selector(swipeView)];
11     
12     // 向下
13     UISwipeGestureRecognizer *swipe2 = [[UISwipeGestureRecognizer alloc] init];
14     // 设置轻扫的方向
15     swipe2.direction = UISwipeGestureRecognizerDirectionDown;
16     [self.customView addGestureRecognizer:swipe2];
17     [swipe2 addTarget:self action:@selector(swipeView2)];
18     
19     // 左边
20     UISwipeGestureRecognizer *swipe3 = [[UISwipeGestureRecognizer alloc] init];
21     // 设置轻扫的方向
22     swipe3.direction = UISwipeGestureRecognizerDirectionLeft;
23     [self.customView addGestureRecognizer:swipe3];
24     [swipe3 addTarget:self action:@selector(swipeView3)];
25     
26     // 右边
27     UISwipeGestureRecognizer *swipe4 = [[UISwipeGestureRecognizer alloc] init];
28     // 设置轻扫的方向
29     swipe4.direction = UISwipeGestureRecognizerDirectionRight;
30     [self.customView addGestureRecognizer:swipe4];
31     [swipe4 addTarget:self action:@selector(swipeView4)];
32     
33     
34     
35 }
36 - (void)swipeView4
37 {
38     NSLog(@"轻扫事件右");
39 }
40 
41 - (void)swipeView3
42 {
43     NSLog(@"轻扫事件左");
44 }
45 
46 - (void)swipeView2
47 {
48     NSLog(@"轻扫事件下");
49 }
50 
51 - (void)swipeView
52 {
53     NSLog(@"轻扫事件上");
54 }

 

以上是关于ios手势识别之轻扫的主要内容,如果未能解决你的问题,请参考以下文章

手势识别(点按,长按,轻扫)

iOS开发之手势识别汇总

iOS开发之手势识别汇总

iOS开发中六种手势识别

iOS开发UI高级手势识别器

iOS 手势