开发者

How to convert view in base64 image in iPhone?

开发者 https://www.devze.com 2023-02-06 14:58 出处:网络
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?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消