Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 17,当textContainerInset为UIEdgeInsetsMake(0, -5, 0, -5)且没有文字时,光标与占位图重叠 #1601

Open
CloudlessMoon opened this issue Dec 6, 2024 · 0 comments

Comments

@CloudlessMoon
Copy link

CloudlessMoon commented Dec 6, 2024

Bug 表现
iOS 17,当textContainerInset为UIEdgeInsetsMake(0, -5, 0, -5)且没有文字时,光标与占位图重叠
图片

如何重现
图片

预期的表现
正常情况下,光标不与占位图重叠

原因
QMUITextView.placeholderLabel布局时会考虑kSystemTextViewFixTextInsets,当系统的textView.textContainerInset为 UIEdgeInsetsZero时,文字与边缘的间距为{0, 5, 0, 5},这个间距不能写死,系统是根据textView.textContainer.lineFragmentPadding的值来的,默认为5.0,如下图所示
图片

iOS 17及以上,当textContainerInset为UIEdgeInsetsMake(0, -5, 0, -5)时,也就是为负数时,文字和光标与边缘的间距还是lineFragmentPadding,系统不会考虑textContainerInset为负数的情况,所以就出现了上述的情况
iOS 17以下,当textContainerInset为UIEdgeInsetsMake(0, -5, 0, -5)时,系统会考虑到负数的情况,所以之前的版本就没问题。

解决方案
QMUITextView.allInsets使用self.textContainer.lineFragmentPadding,去掉kSystemTextViewFixTextInsets,iOS 17及以上判断textContainerInset为负数的情况,全版本适用。
图片

其他信息

  • 设备: all
  • iOS 版本: iOS 17.0
  • Xcode 版本: Xcode 16.1
  • QMUI 版本: 4.8.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant