Disable blinking cursor in UITextField?

前端 未结 10 920
日久生厌
日久生厌 2020-12-24 06:31

I\'ve followed the instructions here and succesfully set up a UITextField that gets updated with a UIDatePicker. However the cursor in the UITextField is blinking, which see

10条回答
  •  有刺的猬
    2020-12-24 06:50

    I couldn't get jcm's solution to work. What I ended up doing was to subclass UILabel to mimic a UITextField's interactive functionality without the parts that I didn't want (like the cursor). I wrote a blog post about it here:

    http://pietrorea.com/2012/07/how-to-hide-the-cursor-in-a-uitextfield/

    Basically, the UILabel subclass needs to overwrite isUserInteractionEnabled, inputView, inputViewAccessory and canBecomeFirstResponder. It's only a few lines of code and it makes more sense.

提交回复
热议问题