0
我有一個視圖,其中包含scrollview大圖像的大小,並且我想爲滾動視圖中的位置添加位置指示器,如地圖在遊戲中。在滾動視圖中創建位置指示器「地圖」iOS
我創建了一個較小的視圖頂部的滾動視圖與較小版本的圖像,我想知道如何添加一個矩形相對於滾動視圖的縮放比例的大小和位置在我的更小的視圖,以在小圖像上顯示您當前正在查看的較大圖像的哪一部分?我使用ARC針對iOS 5+。
這裏是我迄今爲止 - 它似乎正確設置的起源,但是當我放大它變得更小的時候就應該得到更大,反之亦然:
int scrollxint = self.scrollView.bounds.origin.x;
int scrollyint = self.scrollView.bounds.origin.y;
int scrollxlength = self.scrollView.contentSize.width;
int scrollylength = self.scrollView.contentSize.height;
int reducedscrollxint = (scrollxint*0.05);
int reducedscrollyint = (scrollyint*0.05);
int reducedscrollxlength = (scrollxlength*0.05);
int reducedscrollylength = (scrollylength*0.05);
areaFrame.frame = CGRectMake(reducedscrollxint, reducedscrollyint, reducedscrollxlength, reducedscrollylength);
[self.mapView addSubview:areaFrame];
任何幫助將非常感激。