'Why Does UITextField Frame Change When Toggling Secure Text Entry?

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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source