滑动

        override func viewDidLoad() {
        super.viewDidLoad()
        
        let redView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.size.width / 2, height: self.view.bounds.size.height / 2))
        redView.backgroundColor = UIColor.redColor()
        self.view.addSubview(redView)
        
//        redView.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2))
        
        //瞬间触发: 作用时间短, 位移相对小, 一般只会触发一次
        //tap/swipe
        //持续触发: 作用时间长或位移相对大, 会定时或相隔一段距离触发
        //pinch/rotate/long press/pan
        
        //快速滑动,在屏幕上停留时间短,距离相对较长
        //每一手势对象对应一个方向
        let leftSwipe = UISwipeGestureRecognizer(target: self, action: #selector(swipe(_:)))
        leftSwipe.direction = .Left //滑向某个方向
        self.view.addGestureRecognizer(leftSwipe)
    }
    
    func swipe(sender: UISwipeGestureRecognizer) {
        print("left")
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容