如何更改MDCTextField占位符文本颜色?

时间:2019-08-01 04:51:51

标签: ios material-components material-components-ios

我当前将其与MDCTextInputControllerOutlined一起使用。 我已经尝试过

self.emailTextField.attributedPlaceholder = NSAttributedString(string: "Email", attributes: [.font: UIFont.ralewayFont(ofSize: 18.0, weight: .semibold), .foregroundColor: UIColor.white])

但不起作用

1 个答案:

答案 0 :(得分:1)

找到了! 将inlinePlaceholderColor的UIColor设置为MDCTextInputControllerOutlined

let emailTextField = MDCTextField()

let emailTextFieldController = MDCTextInputControllerOutlined(textInput: emailTextField)
emailTextFieldController.inlinePlaceholderColor = .white