0
我試着在我的項目中實現this。但我有一些麻煩。我打算使用UiPanGestureRecognizer來改變矩形的大小。據我所知,我應該使用UIVIew和自定義drawRect方法?選擇GLKViewController的一部分
我試着在我的項目中實現this。但我有一些麻煩。我打算使用UiPanGestureRecognizer來改變矩形的大小。據我所知,我應該使用UIVIew和自定義drawRect方法?選擇GLKViewController的一部分
添加操作爲您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
。
我不明白。什麼是currentFrame? –
而且,customView.frame.width是隻能得到的屬性 –
@OkadzakiTomoe固定,它應該是'frame.size.width'。 'customView'是你調整大小的視圖,'currentFrame'只是一個屬性,你應該在手勢結束後保存'customView'的框架,這樣調整大小才能正常工作。 – xoudini