By using [UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:]
, I am able to create a rounded view, such as this:
How could I subtract another path from this one (or some other way), to create a path like this:
Is there any way I can do something like this? Pseudocode:
UIBezierPath *bigMaskPath = [UIBezierPath bezierPathWithRoundedRect:bigView.bounds
byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)
cornerRadii:CGSizeMake(18, 18)];
UIBezierPath *smallMaskPath = [UIBezierPath bezierPathWithRoundedRect:smalLView.bounds
byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)
cornerRadii:CGSizeMake(18, 18)];
UIBezierPath *finalPath = [UIBezierPath pathBySubtractingPath:smallMaskPath fromPath:bigMaskPath];
Actually there is a much simpler way for most cases, example in Swift:
path.append(cutout.reversing())
This works because the default fill rule is the non-zero winding rule.