material-components-ios
material-components-ios copied to clipboard
[TextControls]Truncated MDCOutlinedTextField labels
I've encountered issues where some textfield floating labels are truncated. The placeholder text is also truncated. Is this a known issue? I've also tested on newer devices running on iOS14 and have also seen this issue. The ellipsis issue does not always happens, sometimes it happens on the floating labels and then sometimes it happens on the placeholder label.
I'm testing on iPhone 7 plus simulator iOS 12 MaterialComponents v123.0.0
iPhone 7 Plus iOS 12

iPhone 8 Plus iOS 14

This is not a known issue! Thanks for filing. Are there any specific steps to reproduce or code samples that you can provide to help with debugging?
Here's a sample code that I used to render the username/password fields
textfield.label.text = label textfield.tintColor = .lightGray textfield.setTextColor(color, for: .normal) textfield.setTextColor(color, for: .editing) textfield.setOutlineColor(outlineColor!, for: .normal) textfield.setOutlineColor(outlineColor!, for: .editing) textfield.setFloatingLabelColor(color, for: .editing) textfield.sizeToFit()
Testing using iOS 12 seems to always truncate the placeholder and floating label. When I test using a device on iOS 14, this only happens sometimes.
Hi @nguyetv75, thanks for the sample code. Does doing textField.label.lineBreakStrategy = .byClipping fix the issue by any chance?
I guess it fixed the truncation issue but then it causes a different issue. See the attached screenshot below.

anyone able to solve this? i am also facing this issue on ios 12
Hello, I believe this bug was fixed in https://github.com/material-components/material-components-ios/commit/02cf9d713ef6f176e04329c4540f0af2acc86caa, but I don't think there's been a release since then. You could pin to develop and get the latest changes that way though!
it crashes with NSInvalidArgumentException if i include the above fixes.
Well , i found the issue, maybe helpful for someone, on ios 12 and below you need to set cliptobounds to NO, which seem to fix the issue.
Interesting, when you use the version on develop it crashes on iOS 12 and below? Do you know where exactly it crashes? Do you have any steps to reproduce?