Swift3でジェスチャーいろいろ
|
タップ
1 2 3 4 5 6 7 8 |
let tapGesture:UITapGestureRecognizer = UITapGestureRecognizer( target: self, action: #selector(TangoViewController.tapped(_:))) aView.addGestureRecognizer(tapGesture) func tapped(_ sender: UITapGestureRecognizer){ // 処理 print("tap") } |
スワイプ(左)
1 2 3 4 5 6 7 |
let leftSwipe = UISwipeGestureRecognizer(target: self, action: #selector(TangoViewController.leftSwipeView(sender:))) leftSwipe.direction = .left aView.addGestureRecognizer(leftSwipe) func leftSwipeView(sender: UISwipeGestureRecognizer) { print("left Swipe") } |
スワイプ(右)
1 2 3 |
let rightSwipe = UISwipeGestureRecognizer(target: self, action: #selector(TangoViewController.rightSwipeView(sender:))) rightSwipe.direction = .right aView.addGestureRecognizer(rightSwipe) |