2016-04-25 56 views
0

我有UIImage与一些图像。如何添加路径到UIImage,它将删除像素?

而我有UIBezierPath(用户签名)。

如何在UIImage中为alpha删除像素。

就像划伤一些uiimage?

我尝试

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; 

,但它只是画黑线。

回答

3

您正在将YES传递给参数UIGraphicsBeginImageContextWithOptionsopaque。因此,而不是创建透明度,kCGBlendModeClear将填充黑色(因为没有alpha通道要清除)。

解决方法是使用不透明的上下文。

UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0); 
相关问题