使用CoreGraphics框架的擦除或透明笔触问题 [英] Issue with erase or transparent stroke using CoreGraphics framework

查看:55
本文介绍了使用CoreGraphics框架的擦除或透明笔触问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个应用程序中,我试图擦除/透明笔画的 UIImage 的一部分,该图像正在使用CoreGraphics框架绘制( CGContextRef 等。)。在此过程中,我可以通过调用 removeAllObjects消息以一张照片的形式清除图形,但是我无法弄清楚如何擦除图形图像的一部分。天哪!我整天坐在那里,但仍然没有结果,现在它让我丧命。请大家从这里帮助我。简而言之,我的要求是像橡皮擦之类的东西,它可以擦除我的绘图图像的一部分。感谢您的帮助!

In one of my apps, am trying to erase/transparent stroke a part of UIImage which am drawing using CoreGraphics framework (CGContextRef etc..). Well in the process I am able to clear the drawing in one shot by calling "removeAllObjects" message, but I was not able to figure out, how to erase a part of the drawing image. Gosh!! I sat the whole day but still no results, now its killing me. Please guys help me out from here. In short, my requirement is something like an eraser which can erase a part of of my drawing image. Appreciate your help!!

推荐答案

只需执行 CGContextSetBlendMode(context,kCGBlendModeClear)

此调用以如下方式更改颜色混合模式:绘图操作将清除位图而不是使用彩色绘图。

This call changes the color blending mode in such a way that drawing operations would be clearing bitmap instead of drawing with color.

要切换回正常渲染,请执行 CGContextSetBlendMode(context,kCGBlendModeNormal)

To switch back to normal rendering do CGContextSetBlendMode(context, kCGBlendModeNormal)

使用不同的混合模式会很有帮助。

Using different blending modes can be very helpful.

这篇关于使用CoreGraphics框架的擦除或透明笔触问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆