【发布时间】:2012-07-20 10:11:00
【问题描述】:
我有一个包含大图像大小的滚动视图的视图,我想为您在滚动视图中的位置添加一个位置指示器,就像游戏中的地图一样。
我在滚动视图的顶部创建了一个较小版本的图像,我想知道如何在我的较小版本中添加一个相对于滚动视图缩放比例的大小和位置的矩形查看,以在小图像上指示您当前正在查看的大图像的哪一部分?我的目标是使用 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];
任何帮助将不胜感激。
【问题讨论】:
标签: ios uiscrollview position