Resize textField Based On Content

后端 未结 3 928
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 10:37

How can a textField be resized based on content while using auto-layout in an iOS application written in Swift?

The text field will resize as necessary to fit its co

3条回答
  •  时光说笑
    2020-11-29 11:02

    Swift 5

    Simpler way:

    textField.text = "hola"
    textField.frame.size.width = textField.intrinsicContentSize.width
    

提交回复
热议问题