我有一个UIScrollView
它有一个UIImageView
。我想在此imageView
上显示引脚。当我将引脚添加为ImageView
的子视图时,除了缩放引脚上的缩放变换时,一切都非常棒。我不希望这种行为,并希望我的针脚保持不变。UIScrollView ImageView顶部针脚
所以我选择将引脚添加到位于ImageView顶部的另一个视图,并且也是UIScrollView
的子视图。这里的想法,如果你会想象的是有一个图层悬停在地图上,不会缩放,但显示在我绘制它们的地方。
如果ImageView
缩放,则添加到图层视图时的引脚不会进行缩放。然而,问题随后变成了针脚的位置与原始原点x/y不匹配,因为ImageView
已经进行了比例变换。
基本上这是一个带有引脚的地方的自定义地图。我正在尝试让引脚浮起来,而不是放大和缩小我的ImageView,但记住放大时发生的位置。
一些代码:
scrollView = [[UIScrollView alloc] initWithFrame:viewRect];
scrollView.delegate = self;
scrollView.pagingEnabled = NO;
scrollView.scrollsToTop = NO;
[scrollView setBackgroundColor:[UIColor clearColor]];
scrollView.clipsToBounds = YES; // default is NO, we want to restrict drawing within our scrollview
scrollView.bounces = YES;
scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
imageViewMap = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
imageViewMap.userInteractionEnabled = YES;
viewRect = CGRectMake(0,0,imageViewMap.image.size.width,imageViewMap.image.size.height);
//viewRect = CGRectMake(0,0,2976,3928);
[scrollView addSubview:imageViewMap];
[scrollView setContentSize:CGSizeMake(viewRect.size.width, viewRect.size.height)];
iconsView = [[UIView alloc] initWithFrame:imageViewMap.frame];
[scrollView addSubview:iconsView];
代码稍后添加引脚上的一些事件。
[iconsView addSubview:pinIcon];
我被困在试图TP找出如何让我的脚在地图上悬停不动,当规模发生了。
这太棒了我有点生病。我有许多其他令人费解的方法可以做到这一点...非常简单。我切换到这个,它很好。 – malaki1974 2013-07-03 18:42:20