Skip to content

Instantly share code, notes, and snippets.

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
let dataDecoded: Data? = Data(
base64Encoded: base64!,
options: Data.Base64DecodingOptions(rawValue: 0)
guard dataDecoded != nil else {
image = placeholder
image = UIImage(data: dataDecoded!) ?? placeholder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment