Resize textField Based On Content

后端 未结 3 925
被撕碎了的回忆
被撕碎了的回忆 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 10:50

    Swift 3

    var textView : UITextView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        textView = UITextView()
        textView.sizeThatFits(CGSize(width: textView.frame.size.width, height: textView.frame.size.height))
    }
    

提交回复
热议问题