views:

56

answers:

1

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.

A: 

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?

NSResponder
I should have mentioned that all the views in question are peers of the same superview. Perhaps you could explain how to use convertPoint:fromView: instead? The end goal is to STROKE a PATH around the PERIMETER of the overlapping UIImageViews. With ±10 UIImageViews all touching this will be a fairly complex polygon path.
Meltemi
CoreGraphics doesn't offer any functions for extracting the perimeter of a complex, self-intersecting path. It's a non-trivial problem.If the views you're trying to outline are opaque, you might be able to get the effect you want just by drawing around the frame of each one and letting the views occlude the parts of the rectangles that would intersect.
NSResponder