material-components-ios icon indicating copy to clipboard operation
material-components-ios copied to clipboard

[MDCTextField] Can't resize icon image (leadingView and trailing)!!!

Open brunoccy opened this issue 4 years ago • 3 comments

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

Screen Shot 2020-09-15 at 08 59 56

Platform (please complete the following information)

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]

brunoccy avatar Sep 15 '20 12:09 brunoccy

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.

andrewoverton avatar Sep 15 '20 15:09 andrewoverton

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.

i use TextControls+OutlinedTextFields, but how i add floating label effect?

brunoccy avatar Sep 16 '20 02:09 brunoccy

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";

andrewoverton avatar Sep 16 '20 15:09 andrewoverton