Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// show Base64 image in iOS
import UIKit
extension UIImageView {
func setImage(
base64: String?,
placeholder: UIImage? = nil
){
guard base64 != nil else {
image = placeholder
return
}
let dataDecoded: Data? = Data(
base64Encoded: base64!,
options: Data.Base64DecodingOptions(rawValue: 0)
)
guard dataDecoded != nil else {
image = placeholder
return
}
image = UIImage(data: dataDecoded!) ?? placeholder
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment