Reputation: 401
I'm trying to change padding top and padding bottom of text in material design text field.
I already try to apply shape and typography schemes but it had no effect.
This is my code:
// Outlet
@IBOutlet weak var nameTextField: MDCTextField!
// Implementation
nameTextField.placeholder = "Nome"
nameTextField.delegate = self
let nameTextFieldController = MDCTextInputControllerOutlined(textInput: nameTextField)
How can i change these spaces?
**** UPDATE ****
After change textRect by overiding MDCTextField i achieve following result. That is a a great advance. But how can i change the size of border to match text?
Upvotes: 1
Views: 1233
Reputation: 908
If you can extend the MDCTextField
class, then override this method:
override func textRect(forBounds bounds: CGRect) -> CGRect {
return bounds.inset(by: UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 0))
}
Change top
and bottom
values as you wish.
If you cannot access/modify or extend the MDCTextField
class, or if it already has its textRect(:forBounds)
implementation, you can create your own UITextField class such as:
class MyTextField: UITextField{
...
}
NOTE: You can even try to inherit
MDCTextField
class:
class MyTextField: MDCTextField{
...
}
Upvotes: 2