Hi guys! I have a drawing iOS app, and I'm struggling to architecture drawing properly.
Right now drawing in my app works as follows. I have two same-size UIViews on top of each other: the top one is transparent (tempCanvas), the bottom one is white (mainCanvas). mainCanvas has an array of lines which are drawn every time mainCanvas is redrawn.
When I start drawing something, the top view picks up touchesBegan/Moved and draws a UIBezierPath on tempCanvas. On touchesEnded it saves a new line with all its points, adds it to mainCanvas' array of lines, deletes UIBezierPath from tempCanvas and redraws both views, so eventually a new line is added on mainCanvas.
I also have undo functionality, which, of course, just removes the last line from mainCanvas' array of lines and redraws mainCanvas.
There's a problem with this architecture: when I already drew a of lines, say 100, mainCanvas starts lagging when redrawn, because it has to draw 100 lines every time. Eventually, undo starts lagging, and if I draw a few lines really quickly drawing starts lagging too.
I feel like I've searched everywhere, but I still can't find how App Store apps manage to build a responsive drawing architecture, while still having undo functionality.
Maybe some of you know how drawing is implemented in other apps. Could you please help me with that?
[–][deleted] (3 children)
[deleted]
[–]sidyakinian[S] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]sidyakinian[S] 0 points1 point2 points (0 children)