I need to display a profile pic of every user corresponding to his name in a UITableView. Until the image is downloaded I need to show an image with his name\'s first alphabet l
You can use https://github.com/bofiaza/IPImage, but you must to do some corrections in function generateImage()
.
Change this code in source file:
public func generateImage() -> UIImage? {
let view = setupView()
UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, 0.0)
view.drawHierarchy(in: view.bounds, afterScreenUpdates: true)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
print(image ?? "No image")
return image
}
on this:
public func generateImage() -> UIImage? {
let view = setupView()
UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, 0.0)
defer { UIGraphicsEndImageContext() }
guard let currentContext = UIGraphicsGetCurrentContext() else {
return nil
}
view.layer.render(in: currentContext)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
print(image ?? "No image")
return image
}
It will be work correctly!