Reputation: 7306
I have UIImage with some image.
And i have UIBezierPath (user signature).
How to make what path erase pixels in UIImage for alpha.
Simply like scratch some uiimage?
i try
UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, 0.0);
[[UIColor clearColor] setStroke];
[self.blurImageView.image drawAtPoint:CGPointZero];
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeClear);
[self.path stroke];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.blurImageView.image = img;
But it just draw black line.
Upvotes: 0
Views: 235
Reputation: 80951
You're passing YES
into the opaque
parameter of UIGraphicsBeginImageContextWithOptions
. Therefore instead of creating transparency, kCGBlendModeClear
will fill with black (as there's no alpha channel to clear).
The fix is to use a non-opaque context.
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);
Upvotes: 3