滑动

作者: Dove_Q | 来源:发表于2016-08-19 09:14 被阅读10次
        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")
    }

相关文章

网友评论

      本文标题:滑动

      本文链接:https://www.haomeiwen.com/subject/hdkbsttx.html