Prevent user from setting cursor position on UITextField

后端 未结 6 943
执念已碎
执念已碎 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:38

    If you are interested in always keeping your cursor at the end of the text, do this:

    override func closestPosition(to point: CGPoint) -> UITextPosition? {
        return self.endOfDocument
    }
    

提交回复
热议问题