How to set letter spacing of UITextField

前端 未结 7 1061
[愿得一人]
[愿得一人] 2021-01-30 12:55

I have an app in which the user has to type a four digit pin code. All digits have to be at a set distance from each other.

Is there a way to do this if the PinTex

7条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-30 13:27

    Try this code After setting the delegate to the textfield.Hope it will work.

    - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
    {
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:textField.text];
        [attributedString addAttribute:NSKernAttributeName
                                 value:@(5.4)
                                 range:NSMakeRange(0, textField.text.length)];
        textField.attributedText = attributedString;
        return YES;
    }
    

提交回复
热议问题