UITextView自动换行的解法

多行文本,如何让UITextView自动换行,且高度自适应

        view.addSubview(textView)
        let width = UIScreen.main.bounds.width - 40
        let size = textView.sizeThatFits(CGSize(width: width, height: CGFloat.greatestFiniteMagnitude))
        textView.snp.makeConstraints { (make) in
            make.centerX.centerY.equalTo(view)
            make.height.equalTo(size.height)
            make.width.equalTo(width)
        }

 

Leave a Reply

Your email address will not be published. Required fields are marked *