QMUI_iOS
QMUI_iOS copied to clipboard
系统 UITextView 在某些情况下设置了 contentInset 后输入框聚焦时会看到光标抖动
Bug 表现 设置 contentInset 与 textContainerInset 后,textView 成为焦点时不输入等待半秒,placeHolder 会自动左移。
截图
如何重现
- 如 contentInset.UIEdgeInsets.right > textContainerInset.UIEdgeInsets.right 时,placeHolder 会自动左移
// example
let textView = QMUITextView()
textView.contentInset = UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 15)
textView.textContainerInset = UIEdgeInsets(top: 8, left: 10, bottom: 0, right: 10)
return textView
- 如 contentInset.UIEdgeInsets.left > 0 时,placeHolder 会自动左移。
textView.contentInset = UIEdgeInsets(top: 20, left: 5, bottom: 0, right: 10)
textView.textContainerInset = UIEdgeInsets(top: 8, left: 10, bottom: 0, right: 10)
预期的表现 正常情况下,应该是什么表现: placeHolder 不会自动左移,和 text 位置保持一致。
其他信息
- 设备: [例如模拟器、iPhone、iPad]
- iOS 版本: iOS 13.x、12.x
- Xcode 版本: [Xcode 11.2.1 (11B53)]
- QMUI 版本: [4.x.x]
这是系统的 bug,不需要设置 textContainerInsets,只需要设置非 Zero 的 contentInset,并且 textView.frame 发生变化,就会出现。用以下的空白项目可以测试: TestTextView.zip
具体的触发条件是什么、该如何规避、如何修复,后续再处理,在此之间可以利用上面的 Demo 测试出一个符合你业务需求又不会引发 bug 的 contentInset/textContainerInset 值。
好我试试,谢谢你们~
先不关闭 issue,后续处理完会同步进展,再关闭