Control cursor position in UITextField

后端 未结 7 2174
你的背包
你的背包 2020-11-29 00:52

I have a UITextField that I\'m forcing formatting on by modifying the text inside the change notification handler. This works great (once I solved the reentranc

7条回答
  •  北海茫月
    2020-11-29 01:23

    Useful to position at index (Swift 3)

    private func setCursorPosition(input: UITextField, position: Int) {
        let position = input.position(from: input.beginningOfDocument, offset: position)!
        input.selectedTextRange = input.textRange(from: position, to: position)
    }
    

提交回复
热议问题