我正在尝试创建以下注册表单。我无法在文本域图像和占位符文本之间设置空格。我尝试了以下内容:
public ClassName
String static list = "";
Public ClassName (parameters){
list += getReferenceVariable();
}
答案 0 :(得分:0)
你可以这样做,UITextField
extension UITextField {
func setTextIconAndPlaceholder(icon: UIImage, placeholder: String) {
let imageView = UIImageView()
imageView.image = icon
imageView.frame = CGRect(x: 0, y: 0, width: 20, height: 20)
let view = UIView()
view.frame = CGRect(x: 0, y: 2, width: 25, height: 25)
view.backgroundColor = UIColor.clear
view.addSubview(imageView)
self.leftView = view
self.leftViewMode = UITextFieldViewMode.always
self.placeholder = placeholder
}
}