iOS開發UI進階手勢辨識器

來源:互聯網
上載者:User

標籤:

####手勢辨識器
UIGestureRecognizer類

·UITapGestureRecognizer(輕擊)

·UIPinchGestureRecognizer(捏合)

·UIPanGestureRecognizer(平移) 事實調用

·UISwipeGestureRecognizer(輕掃)

·UIRotationGestureRecognizer(旋轉)

·UILongPressGestureRecognizer(長按)

alloc initwithTar
[singleTap requireGestureRecognizerToFail:doubleTap];

####具體實現
//1 單擊
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
[imageV addGestureRecognizer:tap];

//2 雙擊
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction1:)];
//點擊的次數
doubleTap.numberOfTapsRequired = 2;
[imageV addGestureRecognizer:doubleTap];

//雙擊失敗是單擊 ---->雙擊成功,單擊不算
[tap requireGestureRecognizerToFail:doubleTap];

//3 長按
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressAction:)];
[imageV addGestureRecognizer:longPress];


//4 輕掃
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeAction:)];
//屬性:輕掃方向
swipe.direction = UISwipeGestureRecognizerDirectionRight;
[imageV addGestureRecognizer:swipe];

//5 移動 即時調用
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panAction:)];
[imageV addGestureRecognizer:pan];

//輕掃失敗算移動--->輕掃成功 移動失敗
[pan requireGestureRecognizerToFail:swipe];


//6 旋轉
UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(totationAction:)];
[imageV addGestureRecognizer:rotation];


//7 捏合
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchAction:)];
[imageV addGestureRecognizer:pinch];

iOS開發UI進階手勢辨識器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.