获取几个转换后的 UIImageView 的帧的并集?
我收集了大约 10 个重叠的 UIImageView。每个都是矩形,但每个都单独旋转和缩放。是否有任何核心图形技巧可以围绕所有图像的周边绘制路径?
CGRectUnion 可能会给我一个包含所有视图的矩形(尽管我隐约记得一旦将变换应用于视图,框架就未定义),但我想要完成的最终结果应该是一个相当复杂的多边形不是简单的矩形。
I've got a collection of roughly 10 overlapping UIImageViews. Each one is rectangular but each is rotated and scaled separately. Are there any Core Graphics tricks for drawing a path around the perimeter of ALL the images?
CGRectUnion may give me a rectangle encompassing all the views (though I vaguely remember the frame is undefined once transforms are applied to a view) but the end result of what I'm trying to accomplish should be a fairly complex polygon not a simple rect.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 -convertRect:fromView: 方法在各个视图的坐标空间之间进行转换。您说视图重叠,但没有提到视图层次结构是什么样的。
如果他们都是同行并且具有相同的超级视图,那么找到联合矩形应该不会很棘手。如果视图层次结构更复杂,您可能需要首先将它们转换为基坐标。
要处理旋转,您可以将有问题的矩形分解为点,并使用 -convertPoint:fromView: 代替。
一旦获得这些信息,您想用它做什么?
You can use the -convertRect:fromView: method to translate between the coordinate spaces of the various views. You say that the views overlap, but you didn't mention what the view hierarchy looks like.
If they're all peers and have the same superview, it shouldn't be very tricky to find the union rect. If the view hierarchy is more elaborate, you might want to convert them to base coordinates first.
To deal with rotation, you can decompose the rects in question into points, and use -convertPoint:fromView: instead.
What do you want to do with this information once you derive it?