Caps Lock Image on Password Protected UITextField

前端 未结 3 1208
暖寄归人
暖寄归人 2021-01-20 20:20

I am creating an app that requires the use of a USB Keyboard. (The normal touch screen keyboard has been disabled and will not show up.) When the user installs the app for t

相关标签:
3条回答
  • 2021-01-20 20:51

    There is no clean way to do this (that I know of), but it can be done by placing a white image over were the caps lock appears.

    This way, the caps lock image will always be hidden.

    Make sure to place the NSImageView control after the NSSecureTextView control (in the UI Builder), so the image will be drawn after the NSSecureTextView control is drawn.

    0 讨论(0)
  • 2021-01-20 20:52

    You can add Images to the textfiled like in the way given in the sample code given below:

    Swift add icon/image in UITextField

    But to check if you caps lock is on or not, I think there isn't any proper way to do that. Maybe you can check in "textFieldShouldReturn" method if the typed character is uppercase or lower case, every-time time when user types a character.

    0 讨论(0)
  • 2021-01-20 20:59

    Adding a dummy view to the rightView did the trick. Thanks for the input.

    textField.rightView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
    
    0 讨论(0)
提交回复
热议问题