1

I am using TextField by using Material Library. That's what the default implementation(Divider is under the Text Area only).enter image description here

Is there any way to put the divider under the LeftView/Image and decrease the gap between Image and Text (like this).enter image description here

Any help will be appreciated.

Soumen
  • 2,070
  • 21
  • 25
  • i don't have hands of experience on material library.. my suggestion is go with your own custom textfield – Gokul G Jun 26 '17 at 08:56
  • 1
    Let's see if I get any quick workaround with Material or else I will make my own custom textfield. – Soumen Jun 26 '17 at 09:35

2 Answers2

1

this could be the solution for your problem.....

let leftView = UIImageView()
leftView.image = Icon.phone?.tint(with: Color.blue.base)

textField.leftView = leftView
textField.leftViewMode = .always
Najam
  • 1,129
  • 11
  • 32
1

When the leftView is laid out it sets the divider's edge inset equal to it's (the leftView) width. So you're going to need to change that. I am subclassing TextField, so I just overrode layoutSubviews.

override func layoutSubviews() {
    super.layoutSubviews()
    dividerContentEdgeInsets.left = 0
}
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
flavs
  • 11
  • 1
  • 2