Use the attribute of the leftViewtext box and place there UIImageViewto place the image on the left side of the text box.
tf.leftView = UIImageView(image: #imageLiteral(resourceName: "usericon2"))
If you want to always show it, change the leftViewMode property of the text field:
tf.leftViewMode = .always
source
share