6

When changing the value of secureTextEntry on a UITextField the font changes. Does anybody know why and how to change this behaviour or how to work around it? No custom fonts involved, only system font.

Gif of problem in action

Code:

let image: UIImage?
if self.passwordField.secureTextEntry == true {
    let content = self.passwordField.text
    self.passwordField.secureTextEntry = false
    [...]
} else {
    self.passwordField.secureTextEntry = true
    [...]
}

Dumped self.passwordField.font on changes and doesn't seem to be changed

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • see http://stackoverflow.com/questions/19475918/change-uifont-in-secure-uitextfield-strange-behaviour-in-ios7 – aaisataev Jan 12 '16 at 12:25
  • 3
    Also http://stackoverflow.com/q/20969451/887210 –  Jan 12 '16 at 12:26
  • 1
    I haven't tested it but this comment specifically addresses the font issue on toggling `secureTestEntry`: http://stackoverflow.com/a/31811916/887210 –  Jan 12 '16 at 12:34
  • Thanks Kenneth, that solution (resignFirstResponder) worked. Unfortunately I haven't found the first thread before, shame on me :( – Jan Schmidt Jan 12 '16 at 13:07

0 Answers0