This code make changes to the imageview, but it replaces its original image. I need to edit on the original image not to replace it.
- (void)drawShapes {
//NSLog(@"In drawShapes!");
UIGraphicsBeginImageContext(self.planView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
for(myShape *i in _collection) {
[self drawShapesSubroutine:i contextRef:context];
if(i.selected == true) {
CGContextSetLineWidth(context, 1.0f);
CGContextSetStrokeColorWithColor(context, [[UIColor darkGrayColor] CGColor]);
float num[] = {6.0, 6.0};
CGContextSetLineDash(context, 0.0, num, 2);
CGRect rectangle;
[self drawShapeSelector:i selectorRect: &rectangle];
CGContextAddRect(context, rectangle);
CGContextStrokePath(context);
//tapped = true;
}
}
if(!skipDrawingCurrentShape && (selectedIndex == -1)) {
[self drawShapesSubroutine:_currentShape contextRef:context];
}
self.planView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
When I remove this line:
self.planView.image = UIGraphicsGetImageFromCurrentImageContext();
The image doesn't disappear but also doesn't draw. I need to draw without removing the original photo.