在swift中滑动多个UIViews

时间:2015-05-04 14:34:40

标签: swipe

我需要使用向下,向上,向左和向右的视图滑动手势。但是在快速UISwipeGestureRecognizer上预先确定了正确的方向。我不知道如何使用其他方向。

1 个答案:

答案 0 :(得分:0)

您也可以使用代码和Storyboard实现不同的滑动方向。

  1. 使用代码

    var swipeLeft = UISwipeGestureRecognizer()
    swipeLeft.direction = UISwipeGestureRecognizerDirection.Left
    //Use following Directions as you need
    //UISwipeGestureRecognizerDirection.Right
    //UISwipeGestureRecognizerDirection.Up
    //UISwipeGestureRecognizerDirection.Left
    
  2. 使用Storyboard:

    选择手势,然后在“属性”检查器中选择方向。看屏幕截图。 enter image description here

  3. 注意:4个方向需要4种不同的手势识别器

相关问题