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
Simple little extension, can be customised as needed.
public extension UIImageView {
func addInitials(first: String, second: String) {
let initials = UILabel(frame: CGRect(x: 0, y: 0, width: self.bounds.width, height: self.bounds.height))
initials.center = CGPoint(x: self.bounds.width / 2, y: self.bounds.height / 2)
initials.textAlignment = .center
initials.text = first + " " + second
initials.textColor = .black
self.addSubview(initials)
}
}