4

Is it posible to change the placeholder text alignment in a MDCTextField that is using MDCTextInputControllerUnderline?

What I am looking for is despite the placeholder appears like this:

Place holder

.............................

I want it at the middle

      Place holder

.............................

Thank you in advance!

Kevin Sanchez
  • 2,215
  • 2
  • 11
  • 19

1 Answers1

0

yes you can if you can override this method of textfield

 override func placeholderRect(forBounds bounds: CGRect) -> CGRect {
    var rect = super.placeholderRect(forBounds: bounds)
    rect.origin.x = rect.origin.x + CGFloat(paddingyouwant)

    return rect
}
Devil Decoder
  • 966
  • 1
  • 10
  • 26
  • I tried it but doesn't works for me, I added an extension for MDCTextField but i think the MDCTextInputControllerUnderline is changing everything. It doesn't works neither the placeholder inside the textfield nor the floating one when the textfield is selected. – Kevin Sanchez Jul 19 '18 at 14:49