您现在的位置: IOS教程網 >> IOS系統 >  >> iOS 程式開發 >> iOS 開發綜合

iOS 七種手勢總整理

編輯:iOS 開發綜合

手勢是行動裝置的重要互動方式。UIGestureRecognizer 可處理多種觸控行為,常見有七種。

常用手勢

輕拍 UITapGestureRecognizer、捏合 UIPinchGestureRecognizer、旋轉 UIRotationGestureRecognizer、平移 UIPanGestureRecognizer、螢幕邊緣輕掃 UIScreenEdgePanGestureRecognizer、長按 UILongPressGestureRecognizer、輕掃 UISwipeGestureRecognizer。

基本用法

建立手勢物件並設定 target 與 action,再透過 addGestureRecognizer 加入視圖。若 UIImageView 需要接收手勢,記得開啟 userInteractionEnabled。

多手勢共存

同一視圖可加入多種手勢。若要讓它們同時辨識,可實作 gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: 並回傳 YES。

在手勢回呼中,可透過 sender.view 取得作用視圖,並依需求做位移、縮放、旋轉或提示。

  1. 上一篇文章:
  2. 下一篇文章:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © IOS教程網 All Rights Reserved