我正在尝试创建一个拼写应用程序,但遇到了困难。用户将听一些单词并尝试书写。我试图在UITextField上单独插入下划线以将每个字符分开。每个下划线都会向用户提供有关单词中存在多少个字符的提示。问题是一些字母如"i"和"l"非常接近,我无法给每个字母放置相同大小的下划线。我可以使用以下方法更改UITextField上字符之间的空白长度
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:strText];
[attributedString addAttribute:NSUnderlineStyleAttributeName
value:@(13)
range:NSMakeRange(0,[strText length] )];
txtTexts.attributedText = attributedString;
但是它会改变整个文本框的长度。我需要每个字母都有不同的长度。有些单词看起来很好,如下图所示:
![enter image description here](https://istack.dev59.com/c4g61.webp)
![enter image description here](https://istack.dev59.com/yJayL.webp)