Iam使用CosmicMind / Material框架试图在占位符的左侧放置一个图标但是占位符和图像在这里相互叠加是我的代码
Txtemail.placeholder = "EmailAdress"
Txtemail.detail = "This EmailAdress is Not Valid"
Txtemail.delegate = self
Txtemail.placeholderNormalColor = Color.black
Txtemail.placeholderActiveColor = Color.pink.base
Txtemail.dividerNormalColor = Color.cyan.base
Txtemail.tag=Example.Email.rawValue
imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 20, height: 20))
image = UIImage(named: "email.png");
imageView.image = image;
Txtemail.leftViewMode = UITextFieldViewMode.always
Txtemail.leftView = imageView
这是结果
我在做错了什么?提前谢谢答案 0 :(得分:3)
尝试不设置框架CGRect(x: 0, y: 0, width: 20, height: 20)
。
试试这个:
let leftView = UIImageView()
leftView.image = Icon.phone?.tint(with: Color.blue.base)
textField.leftView = leftView
textField.leftViewMode = .always
另外,请尝试TextField Sample