Erasing on UIImageView

后端 未结 3 1961
庸人自扰
庸人自扰 2021-01-31 06:05

How can I erase content on front UIImage by swiping finger on it and display UIImage that is back side of UIView.

I had used following code in - (void)touchesMoved

3条回答
  •  长发绾君心
    2021-01-31 06:45

    You can Achive this via blending two images

    Many ways are there simple way is below, you can use GPUImage also..

    just you need to blend two images with your desired output.

    Blend two images on each other..

    Blend more you can try

    **kCGBlendModeOverlay,kCGBlendModeSoftLight,kCGBlendModeColorDodge,etc**
    

    in CGBlendMode parameter in below function.. there are still many option are there to overly two images and merged..(even with live camera also you can do this)

    -(UIImage *)blenimagwithimage:(NSString *)imagename mode:(CGBlendMode)kmode with:(float)opeticy
        {
            processedimage=nil;
            UIImage *inputImage;
            inputImage = [UIImage imageNamed:imagename];
            UIGraphicsBeginImageContext(originalImage.size);
            [originalImage drawInRect:CGRectMake(0.0, 0.0, originalImage.size.width, originalImage.size.height)];
            [inputImage drawInRect:CGRectMake(0.0, 0.0, originalImage.size.width, originalImage.size.height) blendMode:kmode alpha:opeticy];
            UIImage *layeredImage = UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext();
            return layeredImage;
        }
    

提交回复
热议问题