I currently need to calculate/ find the frame in an overlapped area of two UIViews. As an example, I have attached an image of two UIViews overlapping, as well as a white outline of the area/ frame that I would like to calculate – the output should be the frame of the overlapped area.
There is no code at the moment as the problem only requires two simple UIViews with slightly varied frames (to which they will to be compared).
Thanks in advance 😄
2
Answers
I managed to find
CGRectIntersection(_:_:)
in Apple's documentation (https://developer.apple.com/documentation/coregraphics/1455346-cgrectintersection) and was able to discover that the frame of the overlapped area (of two intersecting frames) can be found using the following:For anyone interested, here’s the Mathematical version: