Swipe gesture in Swift 3

后端 未结 7 1230
感动是毒
感动是毒 2020-12-07 17:33

Im trying to get a UISwipeGestureRecognizer to work in Swift 3, the default swipe right is working correctly though not up down or left.

I have tried it by control d

7条回答
  •  醉话见心
    2020-12-07 18:03

    In, Swift 3 you can try this.

    let swipeRightOrange = UISwipeGestureRecognizer(target: self, action:#selector(slideToRightWithGestureRecognizer))
    swipeRightOrange.direction = UISwipeGestureRecognizerDirection.Right;
    
    let swipeLeftOrange:UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(slideToLeftWithGestureRecognizer))
    swipeLeftOrange.direction = UISwipeGestureRecognizerDirection.Left;
    
    @IBAction func  slideToLeftWithGestureRecognizer(gestureRecognizer:UISwipeGestureRecognizer)
    {
    viewOrange.backgroundColor = UIColor.blueColor()
    }
    @IBAction func slideToRightWithGestureRecognizer
    (gestureRecognizer:UISwipeGestureRecognizer)
    {
    viewOrange.backgroundColor = UIColor.lightGrayColor()
    }
    

提交回复
热议问题