Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

convert image to base64 in swift ui

   func convertImageToBase64(image: UIImage) -> String? {
    let imageData = image.jpegData(compressionQuality: 1)
    return imageData?.base64EncodedString(options: 
    Data.Base64EncodingOptions.lineLength64Characters)
   }
Comment

convert image to base64 swift Ui

//Use image name from bundle to create NSData
let image : UIImage = UIImage(named:"imageNameHere")!
//Now use image to create into NSData format
let imageData:NSData = UIImagePNGRepresentation(image)!

//OR next possibility

//Use image's path to create NSData
let url:NSURL = NSURL(string : "urlHere")!
//Now use image to create into NSData format
let imageData:NSData = NSData.init(contentsOfURL: url)!

let dataDecoded : Data = Data(base64Encoded: strBase64, options: .ignoreUnknownCharacters)!
let decodedimage = UIImage(data: dataDecoded)
yourImageView.image = decodedimage
Comment

PREVIOUS NEXT
Code Example
Swift :: play sound in swift 5 
Swift :: get length of array swift 
Swift :: xcode get info from text field 
Swift :: add border to button swiftui 
Swift :: get device name swift 
Swift :: play sound swift stack overflow 
Swift :: swiftui padding one line 
Swift :: swift collection view cell size 
Swift :: swift + time delay call main thread 
Swift :: run a function only once swift 
Swift :: limit log file size swift 
Swift :: swift play audio stream from url 
Swift :: swift 5 make a phone call 
Swift :: swift uiview gradient 
Swift :: for each swiftui 
Swift :: post API Call in swift 
Swift :: swift replace all characters except numbers 
Swift :: swift order dictionary by key 
Swift :: how to set the spacing of a collection view swift 
Swift :: swift completion handler 
Swift :: for loop swift 
Swift :: swift get current hour 
Swift :: swift programmatically set font 
Swift :: UIFont.init bold 
Swift :: and or in swift 
Swift :: How to remove the last item from an array in swift 
Swift :: Swift Named Tuples 
Swift :: how to limit ui field in ios 
Swift :: UIApplicationWillEnterForeground 
Swift :: swift output 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =