选择GLKViewController的一部分

时间:2016-02-08 15:40:13

标签: ios swift uiview selection drawrect

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

1 个答案:

答案 0 :(得分:1)

为您的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