0

enter image description here

I am trying to use MDCTextField https://material.io/develop/ios/components/textfields/ . I need it to be the same as an example. But I always get the result as in the picture. I've already tried

controller.textInsets(UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16))

But it does not work. I am using storyboard. Here is my code.

@IBOutlet weak var uiAddHost: MDCTextField!

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    let controller = MDCTextInputControllerOutlined(textInput: uiAddHost)
    controller.activeColor = Colors.graphRed
    controller.disabledColor = Colors.site_green
    controller.textInsets(UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16))
}
mag_zbc
  • 6,801
  • 14
  • 40
  • 62
Kirk_hehe
  • 449
  • 7
  • 17

1 Answers1

1

try this

@IBOutlet weak var uiAddHost: MDCTextField!
var controller: MDCTextInputControllerOutlined?

override func viewDidLoad() {
    super.viewDidLoad()
    controller = MDCTextInputControllerOutlined(textInput: uiAddHost)
    controller.activeColor = Colors.graphRed
    controller.disabledColor = Colors.site_green
    controller.textInsets(UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16))
}

I had the same problem. I solved it with the code above, but I don't know why this works.

Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35
임소하
  • 19
  • 3