6
votes

I think that my question is related to thread. I have a login screen with two UITextFields (user/pass). Both are horizontally center aligned with placeholder text. When I press a field, the placeholder text jumps a bit to the left and the marker is positioned after the first character (which looks awful).

Text field in focus.

When I start typing, the clear button appears (as it should) but the text is not correctly centered in the UITextField view.

Textfield with text

The problem only occurs when a text field has first responder.

How can I make the darn text and placeholder text stay in the center of the text field???

UPDATE: Text field settings in Storyboard:

Text field settings in Storyboard

2
remove clear button=) Or add the view with the same size into leftView, and the same mode of displayingOssir
NOOOOO :) Granted, that solves the problem but that can't be the only option. I would really like to have the clear button pop up when editingChuckels5584
post your code for referenceNANNAV
There is no code altering the text field. It's all done in Storyboard. See added screenshot of settings.Chuckels5584

2 Answers

0
votes

I had the same problem and what I did is that I've created my custom control that has UITextField above and UILabel below both controls has the same width and height. When I need to display text placeholder I set label alpha to 1 and when I need to hide placeholder I set alpha to 0. Also I set text inoput bg color to clear color. In addition to do all of this I implement UITextFieldDelegate (textFieldDidBeginEditing/ textFieldDidEndEditing/ shouldChangeCharactersInRange)

-1
votes

Please see the control alignment in the below image and set accordingly. It will solve your problementer image description here