开发者

Get union of the frames of several transformed UIImageViews?

开发者 https://www.devze.com 2022-12-10 16:44 出处:网络
I\'ve got a collection of roughly 10 overlapping UIImageViews. Each one is rectang开发者_StackOverflowular but each is rotated and scaled separately. Are there any Core Graphics tricks for drawing a p

I've got a collection of roughly 10 overlapping UIImageViews. Each one is rectang开发者_StackOverflowular 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.


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号