斯威夫特Base64格式 [英] Swift Base64 Format
本文介绍了斯威夫特Base64格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这个网站上,例如当您在图像中下降,它变成了一个正确的Base64格式:的http:// base64image .ORG /
在我的雨燕的应用程序,这里是我要生成一个图像一个base64字符串:
让= IMAGE_DATA UIImagePNGRe presentation(default_image)
让base64String = IMAGE_DATA!.base64En codedStringWithOptions(.Encoding64CharacterLineLength)
这给了我类似的东西,但它有空格和换行。我如何获得一个输出,就像从上面的网站上的输出?
解决方案
让= IMAGE_DATA UIImagePNGRe presentation(default_image)
让base64String = IMAGE_DATA!.base64En codedStringWithOptions([])//不要问换行
如果您删除换行的要求,是否符合你期待什么呢?
On this website, for example when you drop in an image, it is turned into a proper base64 format: http://base64image.org/
In my Swift app, here is what I have to generate a base64 string from an image:
let image_Data = UIImagePNGRepresentation(default_image)
let base64String = image_Data!.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)
This gives me something similar, but it has spaces and line breaks. How do I get an output just like the output from the website above?
解决方案
let image_Data = UIImagePNGRepresentation(default_image)
let base64String = image_Data!.base64EncodedStringWithOptions([]) // Don't ask for line breaks
If you remove the request for line breaks, does it match what you're expecting?
这篇关于斯威夫特Base64格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文