开发者

iOS Sequential Drawing Without Erasing Previously Drawn

开发者 https://www.devze.com 2023-02-20 22:30 出处:网络
I am simply trying to draw a bunch of lines to a view, depending on user interaction. For example, the 开发者_开发知识库user presses a button, and one line is drawn. The user presses another button, a

I am simply trying to draw a bunch of lines to a view, depending on user interaction. For example, the 开发者_开发知识库user presses a button, and one line is drawn. The user presses another button, and another line is drawn, but the first one is still there, and so on. It seems like a trivial task, but from what I've been reading, non-destructive drawing is not very straightforward. Can anyone guide me in the right direction, ideally towards some sample code? Any kind of guidance is really appreciated though, of course. Literally just need to keep drawing various straight lines onto a view. Thanks in advance for any help!


If you want to use Quartz Core, i believe you will have to re draw the whole thing every time...So someone adds a line, you draw the line, they add another line, you add both lines and so on...but you might be able to draw on layers and keep adding them on top of each other..


If you don't need undo capability, try drawing to a CGBitmapContext, then creating an image from it and rendering that to the screen as needed. This is called "back buffering" (or "double buffering" or just "buffered drawing") and is very common.

0

精彩评论

暂无评论...
验证码 换一张
取 消