In Missing Word, I need to get the exact bounds of the missing word and put a same-sized UITextField onto it.
Thanks to the power of TextKit which was introduced in iOS 7, this task can be accomplished pretty easily.
Why do I need the missing word’s exact bounds instead of the position?
If you use hint, you’ll notice the hint letters are not popping out from nowhere, they are appearing like part of the textField’s text.
Check out the letters inv in the above image. Actually, in is in the textView and v is in the textField.
One flaw, Misaligned Images
Turn on the
Color Misaligned Images of the simulator, you’ll notice this:
The reason is that the “exact bounds” of the missing word look like this:
These fractional parts will create a bit of blurriness of your text:
If you want the text to look sharp, you’ll need to use set the textFiled’s position pixel-aligned. But under that situation, the letter v looks one pixel lower:
Missing Word is available on the app store. iTunes link