在切换安全文本条目时,为什么UITEXTFIELD框架会更改?

发布于 2025-01-30 16:26:58 字数 799 浏览 2 评论 0原文

我有一个uitextfield,其中包含一个尾随的按钮,可以切换文本字段的issecureentry值。切换issecureentry的逻辑按预期工作,但是当切换issecureentry时,文本字段的框架高度扩展或高度约为2.5点。

用于按钮测量的两个图像资产72x72点,因此我认为更改不是更改按钮的图像的结果。

我们正在使用自定义字体,因此我认为在iSseCureentry的每个切换之后,我可能需要重置字体(文本字段的插入高度也受到影响)。我采取的步骤如下:

  1. 我已订阅uitextfield.textdidchangenotification s,以便在issecureentry之后设置字体,假设字符的更改将变更导致通知发布,但这似乎没有发生,因为未触发选择器上的断点。

  2. 我使用相同的逻辑为touchupinside事件的按钮选择器中的文本字段设置,但这也不能解决帧更改。

issecureentry切换时,可能导致文本字段的帧更改是什么?

I have a UITextField that contains a trailing-edge button to toggle the text field's isSecureEntry value. The logic for toggling isSecureEntry works as expected, but the frame of the text field expands or contracts in height by a ~2.5 points when toggling isSecureEntry.

enter image description here

The two image assets used for the button measure 72x72 points, so I don't think the change is a result of changing the button's image.

We are using a custom font, so I thought that I may need to reset the font after each toggle of isSecureEntry (the text field's caret's height is also affected). The steps that I took follow:

  1. I have subscribed to UITextField.textDidChangeNotifications in order to set the font after isSecureEntry is toggled, assuming that the change of characters would cause the notification to be posted, but that doesn't seem to happen because the breakpoint placed at the selector is not triggered.

  2. I used the same logic to set the text field's font in the button's selector for the touchUpInside event, but that does't resolve the frame change either.

What may be causing the frame change of the text field when isSecureEntry is toggled?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文