Prevent user from setting cursor position on UITextField

后端 未结 6 949
执念已碎
执念已碎 2020-12-17 17:03

I have an UITextField constructed using the storyboard. I want to not allow the user to change the position of the cursor and keep it always at the end of the text into the

6条回答
  •  星月不相逢
    2020-12-17 17:32

    Think in layers and of controls as tools that you can combine to achieve functionality.

    If you simply place a UIButton over top a UITextField and change the button type to Custom, you can prevent all touch events on the text field such as moving the cursor, selecting text, copying, cutting, and pasting.

    By default, a custom button is transparent.

    Create an action so that when the button is touched, the text field becomes the first responder.

提交回复
热议问题