informatiker informatiker - 1 year ago 360
iOS Question

Swift add icon/image in UITextField

I would like to add icon/image in UITextField. The icon/image should be left to placeholder.

enter image description here

I tried this:

var imageView = UIImageView();
var image = UIImage(named: "email.png");
imageView.image = image;
emailField.leftView = imageView;


Answer Source

Try adding emailField.leftViewMode = UITextFieldViewMode.Always

(Default leftViewMode is Never)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download