I have a UIView
. Inside this UIView
, I have two intersecting subviews. I want to draw a common outline between these two sub-UIViews
. How do I get about this?
To make it clear:
[mainView addSubview:subView1];
[mainView addSubview:subView2];
I need to draw an outline for both these intersecting UIView
s.
You can combine shapes of both rectangles and create new sublayer from the final shape. This layer will act as your outline.
See my code, its fully commented:
Output looks like this:
Edit: I misunderstood the question at first. Below is my original answer which outlines rects intersection.
You can just create another view which will be representing the intersection and add it above the two subviews. It's frame would be intersection of the
subView1
andsubView2
frame
s. Just give it clear background color and border using itslayer
propertyYour code could look like this: