用CGContext绘图后擦除 [英] Erasing after drawing with CGContext

查看:118
本文介绍了用CGContext绘图后擦除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为iPad绘制一个简单的绘图应用程序,您可以在其上绘制图片,而我正在使用CGContext的东西来完成它,但我最初计划处理擦除的方式是仅仅绘制一些东西白色...除了我刚刚意识到当你在绘制另一个图像时它不起作用,因为当你擦除时你也会擦除背景图像。

I'm trying to do a simple drawing app for the iPad where you can draw on a picture, and I'm using CGContext stuff to do it but the way I originally planned on handling erasing was to just draw over stuff with white...except I just realized today that it doesn't work when you're drawing onto another image because then when you "erase" you'll also "erase" the background image as well.

有没有办法支持实际的擦除?

Is there any way to support actual erasing?

谢谢!

推荐答案

在图像上方的图层中显示用户的绘图。然后擦除就像在绘图层上绘制透明贴片一样简单,以便让它下方的图像像素显示出来。

Display the user's drawing in a layer above the image. Then erasing is as simple as drawing a transparent patch on the drawing layer in order to let the image pixels below it show through.

这篇关于用CGContext绘图后擦除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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