[iOS/Swift] UITextView 높이 유동적으로 바꿀 때 뭔가 실시간으로 바뀌지 않는 경우

김혜수·2022년 7월 4일
0

높이의 Relation을 Greater than 으로 바꿔준다.


func textViewDidChange(_ textView: UITextView) {
        let size = CGSize(width: view.frame.width, height: .greatestFiniteMagnitude)
        let estimatedSize = textView.sizeThatFits(size)
        textView.constraints.forEach { (constraint) in
            if constraint.firstAttribute == .height {
                constraint.constant = estimatedSize.height
            }
        }
    }
profile
iOS를 좋아하는 사람

0개의 댓글