iOS

iOS ) 간단하게 Pan Gesture Recognizer 사용하는 방법 with Storyboard

유사앱등이 2022. 6. 6. 02:59

 

 스토리보드로 Pan Gesture Recognizer를 사용하는 방법을 살펴보자

 

 

object library에서 뷰컨트롤러로 가져오면 알아서 자리잡음

컨트롤+드래그로 뷰컨트롤러 파일에 연결

Outlet 하나 연결해주고

Action 하나 연결해주고..

이 때, Type - UIPanGestureRecognizer로 선택

 

viewDidLoad() 안에서 원하는 뷰와 gesturerecognizer를 연결해줌

'scrollView2' 자리에 본인이 원하는 뷰를 입력해주면 됨

 

아까 연결한 IBAction func 에서 원하는 기능을 작성해주면 끝!

아주 간단합니다.

 

 

 

참고:

아래 사이트에서 코드로 사용하는 방법도 볼 수 있고,

여러 가지 예시를 확인할 수 있음.

https://guides.codepath.com/ios/Using-Gesture-Recognizers#step-2-instantiate-the-gesture-recognizer

 

Using Gesture Recognizers | CodePath iOS Cliffnotes

Gesture recognizers are a powerful and easy to use tool for handling user gestures like tap or pinch and performing actions like triggering animations or view changes. This is a quick guide for the steps in setting up gesture recognizers. Gesture Recognize

guides.codepath.com