material-components-ios
material-components-ios copied to clipboard
[MDCTextField] Can't resize icon image (leadingView and trailing)!!!
I cant resize the leadingView size, i try change all values of frame and constraint...
Reproduction steps
`
let view = MDCTextField(frame: .zero)
view.placeholder = "Password"
self.passwordController = MDCTextInputControllerOutlined(textInput: view)
view.font = UIFont.systemFont(ofSize: 20.0)
var image = UIImage(named: "eye-inactive")?.withTintColor(UIColor.blue, renderingMode: .alwaysOriginal)
let iconView = UIImageView(image: image)
iconView.frame = CGRect(x: 0, y: 0, width: 20, height: 20)
let iconContainer = UIView(frame: CGRect(x: 0, y: 0, width: 20, height: 20))
iconContainer.addSubview(iconView)
view.systemLayoutSizeFitting(CGSize(width: 20, height: 20))
view.leftView?.widthAnchor.constraint(equalToConstant: 20).isActive = true
view.leftView = iconView
view.leadingViewMode = .always`
Actual behavior
Platform (please complete the following information)
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
Hi @brunoccy, I encourage you to switch to our newer text field offering, specifically the MDCOutlinedTextField
. I don't think it has this issue. To use it add TextControls+OutlinedTextFields
and/or TextControls+OutlinedTextFieldsTheming
to your Podfile, and then #import "MaterialTextControls+OutlinedTextFields.h"
. See our text field docs for more info.
Hi @brunoccy, I encourage you to switch to our newer text field offering, specifically the
MDCOutlinedTextField
. I don't think it has this issue. To use it addTextControls+OutlinedTextFields
and/orTextControls+OutlinedTextFieldsTheming
to your Podfile, and then#import "MaterialTextControls+OutlinedTextFields.h"
. See our text field docs for more info.
i use TextControls+OutlinedTextFields, but how i add floating label effect?
In the new text field's the placeholder is distinct from what we call the text field's label. To set floating label text go like this:
textField.label.text = @"Label text";