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