Space at end of text not visible in right-aligned UITextField

meaning-matters picture meaning-matters · Mar 6, 2014 · Viewed 7k times · Source

I have a right-aligned UITextField. Initially spaces did not appear at the end of the text when editing. This I solved using this: replacing @" " with the non-breaking "\u00a0".

The above, however, only shows the space while editing the text field.

How do I also make spaces at the end of the text visible when the text field is not being edited?

Answer

Marc picture Marc · Jul 31, 2014

Seems like triazotan has a solution involving replacing non breaking space for space https://stackoverflow.com/a/20129483/1247248

rednaw has some potentially better version, but someone was complaining of weird side effects https://stackoverflow.com/a/22512184/1247248

I ended up going with the version of this solution suggested by meaning-matters https://stackoverflow.com/a/22211018/1247248 and that worked for me.

EDIT

It looked like a good fix but I found a problem. When you select inside the text and type the cursor jumps to the end of the line. Turns out I should have gone with triazotan's version https://stackoverflow.com/a/20129483/1247248