Disabling user input for UITextfield in swift

后端 未结 8 742
半阙折子戏
半阙折子戏 2021-02-01 11:55

pretty trivial question, I know. But I can not find anything online.

I need to disable the user from being able to edit the text inside of a text field. So that when the

8条回答
  •  遇见更好的自我
    2021-02-01 12:41

    you can use UILabel instead if you don't want the user to be able to modify anything in your UITextField

    A programmatic solution would be to use enabled property:

    yourTextField.enabled = false
    

    A way to do it in a storyboard:

    Uncheck the Enabled checkbox in the properties of your UITextField

    enter image description here

提交回复
热议问题