代码之家  ›  专栏  ›  技术社区  ›  Okadzaki Tomoe

选择GLKViewController的一部分

  •  0
  • Okadzaki Tomoe  · 技术社区  · 9 年前

    我正在尝试实施 this 在我的项目中。但我有一些麻烦。我计划使用UiPanGestureRecognizer更改矩形的大小。据我所知,我应该使用UIVIew和自定义drawRect方法?

    1 回复  |  直到 7 年前
        1
  •  1
  •   xoudini    9 年前

    为您的添加操作 UIPanGestureRecognizer 和使用 translation :

    func wasDragged(gesture: UIPanGestureRecognizer) {
        let translation = gesture.translationInView(self.view)
        // Do your resizing here, e.g. from a 
        customView.frame.size.width = currentFrame.width + translation.x
        customView.frame.size.height = currentFrame.height + translation.y
    
        if gesture.state == .Ended {
            currentFrame = customView.frame
        }
    }
    

    使用此方法,添加 CGRect 变量来存储 currentFrame .