2
我們之前實現了點擊縮放功能,現在我們決定使用圖標來放大當前正在顯示的內容的中心位置,並且我們希望重複使用我們的點擊縮放代碼,因爲我們想要達到同樣的效果,但現在我們不知道要通過什麼作爲中心點。如何使用滾動視圖縮放到中心?
我們正在使用的
(的CGRect)zoomRectForScale:(浮)標withCenter:(CGPoint)中心
方法,用來接受來自我們使用的自來水縮放手勢識別中心cgpoint ;然而,由於我們不再使用手勢識別器,我們將不得不找出通過它的cgpoint。此外,這種方法適用於水龍頭縮放,所以我不認爲這是我們遇到問題的地方。
我們試着這樣做
centerPoint = [scrollView contentOffset];
centerPoint.x += [scrollView frame].size.width/2;
centerPoint.y += [scrollView frame].size.height/2;
CGRect zoomRect = [self zoomRectForScale:newScale withCenter:centerPoint];
哪些應該計算出當前的中心,然後把它傳遞給zoomRectForScale,但它不工作(它放大的方式向中心的右側)。
我認爲這個問題可能與我們在應用縮放之前傳遞圖像中心這一事實有關,也許我們應該傳遞縮放的中心。有沒有人有這方面的經驗,或對我們應該如何計算中心有任何想法?