Skip to content

Instantly share code, notes, and snippets.

@5minho
Last active March 15, 2018 06:19
Show Gist options
  • Save 5minho/82a9a1165f8c557a283004bb208f9f94 to your computer and use it in GitHub Desktop.
Save 5minho/82a9a1165f8c557a283004bb208f9f94 to your computer and use it in GitHub Desktop.
text 에 따라서 UITextView 의 height를 변경
extension ViewController : UITextViewDelegate {
func textViewDidChange(_ textView: UITextView) {
let expendSize = CGSize(width: textView.frame.width, height : .infinity)
let estimatedSize = textView.sizeThatFits(expendSize)
let heightOffset = estimatedSize.height - CGFloat(37.verticalValueAppliedScreenSize)
self.ratingInputView.snp.updateConstraints { (make) in
make.height.equalTo(heightOffset + CGFloat(95.verticalValueAppliedScreenSize))
}
UIView.animate(withDuration: 0.2) {
self.view.layoutIfNeeded()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment