How to save and load iphone SDK drawing lines

I want to permanently save drawing lines and load drawing lines saved from a project resource ...!

Now I get the x and y position when I touch move event.i I want to save the position of x and y in the local project resource, but I don’t understand ios, I don’t know ...!

And load the saved position x and y from the file of the local project resource ..!

I want to save drawing lines below:

enter image description here

Please help me with great respect ...!

Thank...

+5
source share
2 answers
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

    if(!mouseSwiped) {
        CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeClear);
        UIGraphicsBeginImageContext(ivBack.frame.size);
        [drawImage.image drawInRect:CGRectMake(0,0, self.ivBack.frame.size.width,self.ivBack.frame.size.height)];
        CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
        CGContextSetLineWidth(UIGraphicsGetCurrentContext(), line);
        CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [pickColor CGColor]);
        CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
        CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
        CGContextStrokePath(UIGraphicsGetCurrentContext());
        CGContextFlush(UIGraphicsGetCurrentContext());

 NSData *dataImage=UIImagePNGRepresentation(UIGraphicsGetImageFromCurrentImageContext());
        [dataImage writeToFile:[self SavedImage:(@"1.png")] atomically:YES];
        drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    }
}

which will defenatly solve ur issue

+3
source

x y, , writeToFile. plist.

NSMutableArray *points = ...
[points writeToFile:someFileInTheBundle atomically:YES];

. , , , : https://github.com/kgn/BBlock/blob/master/UIImage%2BBBlock.m

+2

All Articles