How to convert view in base64 image in iPhone?
Hello i have on开发者_如何学JAVAe view in which i can draw lines. Now i want convert it into base64 image, so how to do this? Thanks in advance.
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *imagedata = UIImagePNGRepresentation(viewimage);
NSString *encodedString = [imageData base64Encoding];
where view is the view where lines are drawn.
In addition, for converting NSData into Base64 string you need use a third party code. I advise you to use Base64 category written by Math Gallagher wich i've used with success. This is the link: http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html
精彩评论