Search code examples
iosswiftstoryboarduitextfieldcursor

Set UiTextField cursor on top Swift IOS


I have a TextField in my storyboard with a height of 100 .

When I'm clicking the TextField the cursor is placed in center :

enter image description here

I would like to set the cursor position in the top left corner.

I tried :

let startPosition: UITextPosition = textField.beginningOfDocument

But it seems that the position is already at the beginning and when the height is extended the cursor stay in center.

How can it be done ?


Solution

  • Seems like you want a multiline UITextField. In that case you might want to take a look at UITextView, which should allow for what you want (docs)