Reputation: 45
Working on textfield with floating labels with the help of MaterialComponent pod.Textfield class showing warning like MDCTextField' is deprecated: MDCTextField and its associated classes are deprecated. Please use TextControls instead.Can any one help me how i can fix this.
Upvotes: 1
Views: 329
Reputation: 6465
The warning you are seeing in the IDE is telling you to use TextControls instead of MDCTextField. If you go to Material UI's documentation, you can see that you need to follow these steps to use TextControls:
Add the relevant pods to your Podfile:
pod 'MaterialComponents/TextControls+FilledTextAreas'
pod 'MaterialComponents/TextControls+FilledTextFields'
pod 'MaterialComponents/TextControls+OutlinedTextAreas'
pod 'MaterialComponents/TextControls+OutlinedTextFields'
Run pod install
In the class you want to use the UI component, add the relevant imports:
import MaterialComponents.MaterialTextControls_FilledTextAreas
import MaterialComponents.MaterialTextControls_FilledTextFields
import MaterialComponents.MaterialTextControls_OutlinedTextAreas
import MaterialComponents.MaterialTextControls_OutlinedTextFields
To replace your OutlinedTextField, you can use:
let textField = MDCOutlinedTextField(frame: estimatedFrame)
textField.label.text = "Phone number"
textField.placeholder = "555-555-5555"
textField.leadingAssistiveLabel.text = "This is helper text"
textField.sizeToFit()
view.addSubview(textField)
For other examples, you can head over to the documentation linked above.
Upvotes: 0