滑动

2016-08-19  本文已影响10人  Dove_Q
        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")
    }
上一篇 下一篇

猜你喜欢

热点阅读