如何使用 UIimageview 和第三个 uiimage 缩放 UIScrollView 作为覆盖在顶部的固定宽度和宽度高度
我有一个 UIscrollview ,其子视图是 UIimageView ,当我缩放滚动视图时,一切正常。 像这样:
mapImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"map.png"]];
mapScrollView.contentSize = mapImageView.frame.size;
[mapScrollView addSubview:mapImageView];
mapScrollView.minimumZoomScale = mapScrollView.frame.size.width / mapImageView.frame.size.width;
mapScrollView.maximumZoomScale = 4;
[mapScrollView setZoomScale:mapScrollView.minimumZoomScale];
我将另一个 UIimageview 作为子视图添加到 uiviewimage 的某个位置,如下所示:
userImageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bubble.png"]];
userImageView1.frame = CGRectMake( 300 * 4, 300 * 4, 104 * 4 , 135 * 4 );
[mapImageView addSubview:userImageView1];
[userImageView1 release];
现在,当我缩放时,气泡在地图上移动。 在委托函数中,我这样做:
(void)scrollViewDidZoom:(UIScrollView *)_scrollView{
CGRect frame = userImageView1.frame;
frame.origin.x = ??
frame.origin.y = ??
frame.size.width = 104 /2/_scrollView.zoomScale;
frame.size.height = 135 /2/_scrollView.zoomScale;
userImageView1.frame = frame;
}
为了设置固定宽度和宽度。
我的问题是 X 和高度需要是什么。 Y 以便将图像移动到缩放屏幕中的相关位置。 我如何计算那些 X,Y
10x
Tamir
i have i UIscrollview with a subview wich is UIimageView and when i zoom the scroll view every thing work fine.
like this:
mapImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"map.png"]];
mapScrollView.contentSize = mapImageView.frame.size;
[mapScrollView addSubview:mapImageView];
mapScrollView.minimumZoomScale = mapScrollView.frame.size.width / mapImageView.frame.size.width;
mapScrollView.maximumZoomScale = 4;
[mapScrollView setZoomScale:mapScrollView.minimumZoomScale];
i add another UIimageview as subview to the uiviewimage in a position, like this:
userImageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bubble.png"]];
userImageView1.frame = CGRectMake( 300 * 4, 300 * 4, 104 * 4 , 135 * 4 );
[mapImageView addSubview:userImageView1];
[userImageView1 release];
now the bubble moves on the map as i zoom.
in the delegate function i do this:
(void)scrollViewDidZoom:(UIScrollView *)_scrollView{
CGRect frame = userImageView1.frame;
frame.origin.x = ??
frame.origin.y = ??
frame.size.width = 104 /2/_scrollView.zoomScale;
frame.size.height = 135 /2/_scrollView.zoomScale;
userImageView1.frame = frame;
}
in order to set fixed width & height.
my question is whats needs to be the X & Y in order to move the image to the relevant position in the zoomed screen.
how do i calculate those X,Y
10x
Tamir
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设
UIScrollView
是主视图控制器视图的子视图,为什么不直接将固定宽度UIImageView
添加为UIScrollView< 上方主视图的子视图/代码>?
Assuming that the
UIScrollView
is a subview of your main view controller's view, why not just add the fixed widthUIImageView
as a subview of the main view above theUIScrollView
?