본문 바로가기
개발/swift

[Swift]UIGestureRecognizer 참고자료

by 꼬마상어 2016. 9. 28.
반응형

http://minsone.github.io/mac/ios/uigesturerecognizer



참고하여 나는 이런식으로 썼다!


 override func viewDidLoad() {

        super.viewDidLoad()

        

        initUi()

    

        let swipeUp = UISwipeGestureRecognizer(target: self, action: #selector(self.didSwipe(swipeGes:)))

        let swipeDown = UISwipeGestureRecognizer(target: self, action: #selector(self.didSwipe(swipeGes:)))

        

        swipeUp.direction = .up

        swipeDown.direction = .down

        

        self.view.gestureRecognizers = [swipeUp, swipeDown]

        

        initUi()

    }

    

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

    }

    

    

    func didSwipe(swipeGes : UISwipeGestureRecognizer) {

      

        switch (swipeGes.direction) {

            case UISwipeGestureRecognizerDirection.down:

                print("Swiped down")

            case UISwipeGestureRecognizerDirection.up:

                print("Swiped up")

            default:

                break

        }

    }

반응형

댓글