yucel bayram yucel bayram - 1 year ago 99
Objective-C Question

How to change empty spaces length between characters on UITextField

I am trying to create spelling app but i stuck. User going to listen some word and will try to write it. i am trying to insert underline seperately to every characters on UITextField. Every underline will give a hint to user that how many characters exist in a word. Problem is some letters like "i","l" are so close to each other and i cant put same size underline to every letters. I could change empty blank length between characters on UITextField with this

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:strText];
[attributedString addAttribute:NSUnderlineStyleAttributeName
range:NSMakeRange(0,[strText length] )];

txtTexts.attributedText = attributedString;

But it change for whole textfield with same length. I need different length for every letter. It looks fine with some words like this

enter image description here

But it is not fine with letters like "i" because they are closer to each other. enter image description here

Underlines are UIView by the way. But i m open to any advice.

Answer Source

This is caused by the new SF font. You can use monospaced font.

UIFont.monospacedDigitSystemFontOfSize(, weight: )
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download