How I can substract one CGRect
from another? I want the result R1 - R2
to be the largest subrectangle of R1 that does not intersect R2.
CGRect newRect = CGRectMake(0, 0, rect2.size.width - rect1.size.width, rect2.size.height - rect1.size.height);
In response to your illustration, this code I've given you here will do exactly what you want (assuming you don't care about the origin XY coordinates). I've looked through the docs for CGGeometry functions, and there doesn't seem to be a CGRectDifference
or other such method defined. There is, however, CGRectUnion
, but that does the opposite of what you are looking for.