CosmicMind/Material Textfield 的 PlaceHolder 在左视图上

CosmicMind/Material Textfield's PlaceHolder over left view

我正在使用 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

这是结果

我做错了什么?提前致谢

尽量不设置边框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