cglayer

Undo/Redo for drawing in iOS

寵の児 提交于 2019-11-27 09:36:34
I am working on a drawing app, I want to do Undo/Redo, for this I am saving CGPath on touches ended to NSMutableArray, But I am not understanding how I should render the CGPaths on click of Undo button EDIT1: As I am using BezierPaths, So, I first decided to go with a simple approach of just stroking this path, without CGPath, EDIT2: As my Undo is happening in segments(i,e in parts and not whole path is deleted), I decided to create an array of array, So I have made changes accordingly and now I will be drawing in CGlayer, with taking CGPath So here "parentUndoArray" is array of arrays. So I

Doing Undo and Redo with Cglayer Drawing

懵懂的女人 提交于 2019-11-26 18:37:49
问题 I am working with a drawing app, I am using CGlayers for drawing. On touches ended, I get image out of the layer and store it in a Array, which I use to undo operation. My touches ended function -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Touches ended"); UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextDrawLayerInRect(context, self.bounds, self.drawingLayer); m_curImage =

Undo/Redo for drawing in iOS

試著忘記壹切 提交于 2019-11-26 14:47:07
问题 I am working on a drawing app, I want to do Undo/Redo, for this I am saving CGPath on touches ended to NSMutableArray, But I am not understanding how I should render the CGPaths on click of Undo button EDIT1: As I am using BezierPaths, So, I first decided to go with a simple approach of just stroking this path, without CGPath, EDIT2: As my Undo is happening in segments(i,e in parts and not whole path is deleted), I decided to create an array of array, So I have made changes accordingly and