//Base64转UIImage
class func convertStrToImage(_ imageStr:String) ->UIImage?{
if let data: NSData = NSData(base64Encoded: imageStr, options:NSData.Base64DecodingOptions.ignoreUnknownCharacters)
{
if let image: UIImage = UIImage(data: data as Data)
{
return image
}
}
return nil
}
//UIImage转Base64
class func getStrFromImage(_ imageStr:String) -> String{
let imageOrigin = UIImage.init(named: imageStr)
if let image = imageOrigin {
let dataTmp = image.pngData()
if let data = dataTmp {
let imageStrTT = data.base64EncodedString()
return imageStrTT
}
}
return ""
}