Your post is marked with the keyword "Core-Graphics," so I assume that's what you want to use. To add shapes, you simply draw the 2 or more shapes you want together. I recommend following a pattern of saving the graphics state, drawing your connected shapes, and the restore the graphics state for drawing the next set of shapes. Like this:
// Save the state
CGContextSaveGState (ctx);
// Do your drawing
CGContextBeginPath (ctx);
CGContextAddRect (ctx, rect);
CGContextAddEllipseInRect (ctx, ellipseRect); // Or whatever
CGContextClosePath (ctx);
CGContextFillPath (ctx);
// Restore the state
CGContextRestoreGState (ctx);
To subtract shapes, you can use a clipping path:
// This is the path you want to draw within
CGContextBeginPath (ctx);
CGContextAddRect (ctx);
CGContextClosePath (ctx);
CGContextClip (ctx);
// Now draw the shape you want constrained within the above path
CGContextBeginPath (ctx);
CGContextAddEllipseInRect (ctx, ellipseRect);
CGContextClosePath (ctx);
CGContextFillPath (ctx); // This will fill everything in the path that is also within the clipping path, and nothing that is outside of the clipping path
See also CGContextEOClip()
for other ways to clip shapes.