在CGAffineTransform之后转换父/子UIView之间的坐标 [英] Convert coordinates between parent/child UIView after CGAffineTransform

查看:178
本文介绍了在CGAffineTransform之后转换父/子UIView之间的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我手动完成所有操作之前,我想询问是否有一些帮助可以从框架中获取。

Before I go into doing everything by hand I would like to ask if there is some help to get from the framework.

我有一个UIView,它拥有另一个UIView用地图。父UIView为地图保留了一些图例。最初我在地图视图中定义了一些坐标。例如(100,40),并在父视图中放置一块图形(如谷歌地图中的大头钉等)。父视图和子视图都是300x200并且具有相同的原点。这意味着(100,40)在两个视图中都是相同的点。

I have a UIView that holds another UIView with a map. The parent UIView holds some legends for the map. Initially I define some coordinates in the map view. e.g. (100, 40), and place a piece of graphics there in the parent view (like a tack in google maps etc.). The parent view and the child view are both 300x200 and have the same origin. This means that (100, 40) is the same point in both views.

现在我使用CGAffineTransform和坐标(100)缩放并移动子UIView(地图) ,40)现在位于其他地方。父视图在这里实际上是一个掩码。

Now I zoom and move the child UIView(the map) using CGAffineTransform and the coordinate (100, 40) is now situated somewhere else. The parent view is effectively a mask here.

我可以使用CGAffineTransform矩阵或框架的其他部分来计算并通知父视图在何处放置现在该点已经移动?

ie子视图中的(100,400)与父视图中的(100,40)相比,它与转换后的比较是什么?

谢谢给你建议或帮助。

孩子的动画UIView

The animation of the child UIView

    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    CGAffineTransform transform = CGAffineTransformMakeScale(1.8f, 1.8f);
    worldMap.transform = transform;
    worldMap.bounds.origin = newPos;
    [UIView commitAnimations];


推荐答案

UIView的 -convertPoint:toView : -convertPoint:fromView:应该适合你。

UIView's -convertPoint:toView: and -convertPoint:fromView: should work for you.

这篇关于在CGAffineTransform之后转换父/子UIView之间的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆