我想在UITextField中添加图标/图像。图标/图像应留给占位符。
我尝试了这个:
var imageView = UIImageView();
var image = UIImage(named: "email.png");
imageView.image = image;
emailField.leftView = imageView;
谢谢。
最佳答案
尝试添加emailField.leftViewMode = UITextFieldViewMode.Always
(默认leftViewMode
为Never
)
更新了的答案Swift 4
emailField.leftViewMode = UITextFieldViewMode.always
emailField.leftViewMode = .always