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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With